Setting Up Data Files -- Fixing "Could not load image... URL was null."

I got something to work, but I don’t understand why it works.

I’m working with Netbeans 5.0 on Windows XP.

I have JME installed and the demos working.

I was working on the TestSphere project in the User’s Guide section of the wiki.  If I type in the code exactly as stated I get it to run correctly (spinning sphere with the monkey image on it).  However, I wanted to put the data into my own directory system.  When I started doing this, it still runs, however, the sphere it created was grey and in the Netbeans output I get the message  “Could not load image…  URL was null.”

Now, I experimented with moving around the directory based on the fact that it would work with the original description and got this configuation to work.  The only difference in my code from the code here is that the value:


was replaced with:


and I got it to work by using this file structure for my project:











My question is:  "Why did this work?"  I was poking around in my java books and on the web and couldn't find any answers.  Now, I was doing a little experiment and I saw that this data-images folder combination seems to have also been copied over in under the build directory in the classes file.  So, should the data folders always be included in under the src folder of your project in Netbeans?
What's the general rule for Java?

Thanks in advance.

Rename jmetest/data/images/Monkey.jpg temporarily to make sure You don't use this one as if TestSphere.class.getClassLoader(… will probably use the original TestSphere.class if it is found first in the classpath before Your copy and it's classLoader may load  "data/images/Monkey.jpg"  beneath jmetest.

… then i'd recommend reading the classloader docs to understand where the loader looks for the resources.


Okay, I did that and it still worked.  So, I'm on the right path.

Thanks for the advice on where to look for future research.