How do I use Java getResource() to get a resource from a parent directory?

前端 未结 2 1315
执笔经年
执笔经年 2021-01-17 10:52

I\'ve tried numerous methods now, including FilenameUtils.normalize() from commons IO, but I can\'t seem to be able to get a resource in another folder to get a Java FXML fi

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 11:05

    You can get resources relative to the Class or the context root. In your example putting / at the start of the string if thats your package structure in your application. Try

    getClass().getResource("/gui/dialogues/plugins/PluginSelection.fxml")
    

提交回复
热议问题