Is there a way to programmatically get the name of the .jar
file that was executed? (through Spring
or Java
).
e.g. when running a Java application java -jar myApp
There is no out of the box way to do this. But you can do something like following.
java -Djar.name=myApp.jar -jar myApp
And using following in code;
System.getProperty("jar.name");