1

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

Felix
  • 667
  • 14
  • 28

1 Answers1

1

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");
shazin
  • 21,379
  • 3
  • 54
  • 71