buildpath - Loading resources after refactoring project structure in Eclipse -


i changed build path couple of packages in eclipse project. file structure should have stayed same however. once package main.java.edu.umb.cs edu.umb.cs. links working fine before, i'm getting error tokanagrammar.fxml can't found. following in tokanagrammar.java (the topmost expanded package in image below):

..getresource("../../../../resources/fxml/tokanagrammar.fxml")); 

edit1: code read resources in

public void start(stage primarystage) {      try {         anchorpane page = (anchorpane) fxmlloader.load(tokanagrammar.class.getresource("../../../../resources/fxml/tokanagrammar.fxml"));         scene scene = new scene(page);         primarystage.setscene(scene);         primarystage.settitle("tokanagrammar 0.1");         primarystage.show();      } catch (exception ex) {         logger.getlogger(tokanagrammar.class.getname()).log(level.severe, null, ex);     } } 

again, worked fine before took of src out of build path. far aware, resource not have in build path able accessed. i've had projects have had image folder, instance, outside of build path without problems.

so gives? can move .fxml file package tokanagrammar.java resides , edit link , works fine. however, per specifications has way described.

any appreciated.

package explorer

rather relying on (changing) paths relative tokanagrammar class, should load resource relative root of classpath. true since resource in entirely different package class (as far path resolution goes). try instead:

anchorpane page = (anchorpane) fxmlloader.load(     thread.currentthread().getcontextclassloader().         getresource("fxml/tokanagrammar.fxml")); 

note work long resources in src/main/resources being copied root of class path.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -