简体   繁体   English

如何使用Java查找应用程序安装路径目录

[英]How to find an application installation path directory with java

I have installed my jar application using packjacket, an installer generator. 我已经使用安装程序生成器packjacket安装了jar应用程序。 http://packjacket.sourceforge.net/ http://packjacket.sourceforge.net/

default installation path will be in "../program files/myapp.jar" 默认安装路径将在“ ../程序文件/myapp.jar”中

but how can java language detect different installation path if user decide to change to different path directory during installation. 但是,如果用户决定在安装过程中更改为其他路径目录,那么Java语言将如何检测到不同的安装路径。 (currently i just hard code the default location as C:/../program files/) (当前我只是将默认位置硬编码为C:/../ program files /)

i have read this question, How to find an application installation path in the ms windows registry via EXE name . 我已经阅读了这个问题, 如何通过EXE名称在ms Windows注册表中找到应用程序安装路径 But regrettably still not understand. 但遗憾的是仍然不明白。

ps: im not sure if my jar application have registry path or not because i rely on packjacket installer to install my apps. ps:我不确定我的jar应用程序是否具有注册表路径,因为我依靠packjacket安装程序来安装我的应用程序。

this reference is unclear: find the path of my application installed in registry 此参考资料尚不清楚: 在注册表中找到我安装的应用程序的路径

Your question is a little unclear. 您的问题还不清楚。

Your application should never make assumptions about where it might be stored and should rely on relative paths or know variable paths, such as the user's home directory ( System.getProperty("user.home") ). 您的应用程序永远不要假设它可能存储在哪里,而应该依赖于相对路径或知道变量路径,例如用户的主目录( System.getProperty("user.home") )。

You can find you current "working" directory using System.getProperty("user.dir") 您可以使用System.getProperty("user.dir")找到当前的“工作”目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM