获取运行Jar或Exe的名称 [英] Get name of running Jar or Exe
本文介绍了获取运行Jar或Exe的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要做的是获取正在运行的jar / exe文件的名称(它将是Windows上的EXE,mac / linux上的jar)。我一直在寻找,我似乎无法找到如何。
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 how.
如何获得运行Jar或Exe的名称?
How to get name of running Jar or Exe?
推荐答案
希望这可以帮助你,我测试代码,这将返回完整的路径和名称。
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());
这是找到的在stackoverflow上类似但不是==的问题
如何获取正在运行的JAR文件的路径?
This was found on a similar but not == question on stackoverflow How to get the path of a running JAR file?
这篇关于获取运行Jar或Exe的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文