java - Absolute/Relative path to files in Eclipse -


i working on assignment need use xml file in project. file in folder created called res. res folder under project folder. myproject --> res --> myxmlfile.xml

the .java file calling xml file in src folder. myproject --> javaresources --> src --> edu.unsw.comp9321.assignment1(package) --> myjavafile.java

i wondering how should refer file in java code if want code work when run project on computer?

when use relative path appears searching folder eclipse installed, opposed workspace folder project exists.

this have @ moment:

file fxmlfile = new file("c:/users/giridhaar/workspace/comp9321assignment1/res/xml/musicdb.xml"); 

thank help.

this should work :

file fxmlfile = new file("res/xml/musicdb.xml"); 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -