Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java get location of jar file

//this worked for me
File jarDir = new File(ClassLoader.getSystemClassLoader().getResource(".").toURI());

//this didn't work for me but it is often suggested
File jar = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI());
 
PREVIOUS NEXT
Tagged: #java #location #jar #file
ADD COMMENT
Topic
Name
1+5 =