Doenerstyle Doenerstyle - 2 months ago 12
Java Question

Getting the path of a running JAR file returns "rsrc:./"

My code runs inside a JAR file and I need to get the full path of that file.
For example, my JAR is called example.jar and is located at D:\example\
So I need to get "D:\example\example.jar" by some code inside that jar.
I have tried many methods to get that path, but none of them worked correctly.

One of them is


Many people say that this works for them, but it returns "rsrc:./" for me.

I have searched after that and I noticed that my MANIFEST.MF contains this:

Manifest-Version: 1.0
Rsrc-Class-Path: ./
Class-Path: .
Rsrc-Main-Class: Example
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

I don't know what that means, but if I remove that Rsrc stuff and replace the other things with it, it says the jar is broken. I think this is the reason why it doesn't work. Does anybody know what this means?

PS: I'm running my JAR using a BAT file.


I just have created a new workspace and moved every project into it and everything works fine now, I think it was a bug or something...Thank you all for your help!