There are two different forms for locating folders for a project, depending on whether you start the location with a “/” or not. Using the “/” is an absolute address that starts from the code base, otherwise the location is relative to the location of the class that is used for the call. I’m assuming the form getResource(filename) or getResourceAsStream(filename).
The symbol “…” is useful for backing up one level.
In general URL’s are more reliable, since the file system is unable to locate files embedded in a jar. URL = Uniform Resource Locator. The JavaDocs for URL has more info.
If you have a Class called PlaySound in folder src, and res is a “neighboring” folder (as in your diagram), you should be able to use the following.
URL url = PlaySound.class.getResource("../res/sound");
I did a test where my structure was the following:
jgoQuestions // a package in the Eclipse project
res
foo.txt
src
ResourceTest
From here, the following worked (running the class ResourceTest):
URL url = ResourceTest.class.getResource("../res/foo.txt"); // relative form
URL url = ResourceTest.class.getResource("/jgoQuestions/res/foo.txt"); //absolute form