Answers for "get location of running jar file java"

3

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());
Posted by: Guest on June-24-2020
1

java get jar execution directory

return new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation()
    .toURI()).getPath();
Posted by: Guest on February-19-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language