Back
My code runs inside a JAR file, say foo.jar, and I need to know, in the code, in which folder the running foo.jar is.
So, if foo.jar is in C:\FOO\, I want to get that path no matter what my current working directory is.
The best solution to this problem is to use:
Return new File(NameofClass.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath();
31k questions
32.8k answers
501 comments
693 users