class.getClassLoader().getResource REFUSES to find .svg file

This is a real headscratcher for me. I cannot for the life of me get the class loader to find a .svg resource. I can change the extension to absolutely anything else (e.g. right now I have made them .svh files) and it gives me a valid URL, but I change them back to .svg and I only ever get null. WHAT THE HELL!!

Somebody please save me here.

// This NEVER works
URL url = SVGUtils.class.getClassLoader().getResource("com/acarter/applicationx/data/xml/checkbox_0.svg");

// So I rename the file extension to anything else (e.g. *.svz) and I get a valid URL
URL url = SVGUtils.class.getClassLoader().getResource("com/acarter/applicationx/data/xml/checkbox_0.svz");

Source layout is like this...

|    |- checkbox_0.svg
|    |- checkbox_1.svg
|- com.acater.applicationx.util

never had that issue… is it possible it is your IDE fooling with you?

right, like if you use eclipse, make sure the resource is copied over to the bin dir etc…

MrCoder said:

right, like if you use eclipse, make sure the resource is copied over to the bin dir etc...

Thats exactly the problem! Eclipse is not copying the *.svg files to the bin directory but I can't seem to fix it either. I even tried adding a specific build path inclusion for only svg files, an it still ignored them. I wonder if this is a Eclipe Ganymede bug or something, I've never had these kind of problems before (I also wasn't woking with svg's before Ganymede). And its specific to the extension, weird.

I finally found it. Thanks for the pointers guys.

Project Properties

  Java Compiler


      Workspace Settings

        Output Folder

          Filtered Resources
    <- It was hiding deep in this list  :x

Meh, hate those kind of time sinks…  Glad you found it. :slight_smile: