Revision: 10256
Updated Code
at December 14, 2008 17:21 by resurge
Updated Code
try { File jarFile = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()); } catch (URISyntaxException e) { //do some error handling here }
Revision: 10255
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 14, 2008 17:18 by resurge
Initial Code
try { File jarFile = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()); } catch (URISyntaxException e) { e.printStackTrace(); }
Initial URL
http://www.velocityreviews.com/forums/t147526-how-to-get-jar-file-name.html
Initial Description
The returned file will either contain the folder from where your program is running or the executable jar file, if your program is an executable jar. I'm using `Main.class` because this code is in my main method (which is in the class 'Main'). You can replace `Main.class` by `getClass()` if you want to use this code in a non-static method.
Initial Title
Get active execution location
Initial Tags
java
Initial Language
Java