Get name of running Jar or Exe

前端 未结 5 2111
长发绾君心
长发绾君心 2020-12-03 15:47

What I need to do is get the name of the running jar/exe file (it would be an EXE on windows, jar on mac/linux). I have been searching around and I can\'t seem to find out h

5条回答
  •  独厮守ぢ
    2020-12-03 16:14

    Hope this can help you, I test the code and this return you the full path and the name.

    Maybe you want to play a little more with the code and give me some feed back.

    File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI());‌
    

    This was found on a similar but not == question on stackoverflow How to get the path of a running JAR file?

提交回复
热议问题