How to use a folder of a jar (or zip) file for ResourceLocator


I would like to use a folder of a jar (or zip) file as ressource folder using :

URI uri= new URI("file:///D:/temp/data.jar!/texture/");      
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,new SimpleResourceLocator(uri));

But I need the correct way to write it.

Thank you for your help.

OK I found :

URI uri = new URI("jar:file:/D:/tmp/!/textures/test.txt");
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,new SimpleResourceLocator(uri));

Thats not a bad way to explicitly define the file you want, but an easier way might be to use


(that will include the Jar stuff right into the path for you :), and I think it does work for zip files...)

OK thanks,

but my problem was actually in this : "path_here".

I didn't know how to specify the right path, in order to indicate a folder in a jar file.

with that you just have to supply the path inside the jar file and the rest will be 'tacked' on…


URL url = Thread.currentThread().getContextClassLoader().getResource( "textures/test.txt" );

Would return a URL equal to:



I have to specify that the jar or zip file is an extern file.

I guess there was a tidbit I forgot to mention, in order for that to work the zip or jar file must be included in the classpath.

You solution will work even if the archive is not in the classpath; however defining absolute paths like that places the burden of keeping track of where the 'root' location is on you.

OK thanks anyway for your help.