Classloader problems with eclipse

I have problems with eclipse and loading assets, I’ve mentioned other issues before with no resolution too and perhaps these are related.



I have a jme3 project, and inside it I am using the recommended directory structure like so



build.xml

.project (Eclipse project file)

assets/textures/myimage.png

src

lib





in my code I have a line something like:



[java]

Texture tex_ml = assetManager.loadTexture("assets/textures/myimage.png");

[/java]

assets/textures/myimage.png is on the classpath in both ant and eclipse.



launched via ANT the line above works. however the following 2 fail:



[java]

assetManager.loadTexture("textures/myimage.png");

assetManager.loadTexture("myimage.png");

[/java]

launched via Eclipse the only thing that works is:



[java]

Texture tex_ml = assetManager.loadTexture("myimage.png");

[/java]

the classloader always returns null in eclipse if I use any part of the path.



if I am loading something from a jar it seems to work fine with the relative path – ie



[java]

assetManager.loadTexture("Effects/Explosion/shockwave.png")

[/java]

has anyone else had this problem? know a solution?



Cheers

Have you registerd a assetloader?



Are you sure the path/names are in ExAcT CaSe?



Since I use eclipse too I can at least assure you that it is no eclipse problem.



Make sure the assetfolder is marked as a source folder.

EmpirePhoenix said:
Have you registerd a assetloader?

Are you sure the path/names are in ExAcT CaSe?

Since I use eclipse too I can at least assure you that it is no eclipse problem.

Make sure the assetfolder is marked as a source folder.


ok - so I solved my problem. it turns out that I had my assets/textures folder is marked as a source folder in eclipse.
I changed it so that it was just the assets folder and all is well.

thanks for the hint.

fyi - no I havent registered an assetloader (I thought it wasnt required if I used the recommended assets/.. folder structure, or is that only within jmp?)
I'm not even sure how I should register a loader for a png in a given folder (or subfolder). there are no examples of adding a path to a loader that I can find on this site, only examples of registering a single zip etc.

also - from the ANT side for anyone else who might run into this,
You have to specify the assets folder as a pathelement, ie


if you try to add the assets to the classpath with a fileset it wont work as advertised and you need to include the "assets" part of the path in your code. ie this wont work properly:

Normally you don’t need to register the Loaders, since they are preconfigured for most needs, however you might want to configure the ressourcelocators. There are some aviable (Classpath based, FilesystemBased, Webbased, Zipbased)