在mac os x上的.app内运行时获取jar的路径
我的javafx jar在.app中运行。现在,如果我执行 System.getProperty(user.dir)
我得到用户家的位置,即/ Users / DevAccount /其中DevAccount是系统用户名而不是.app文件或.jar文件的位置。
如何在运行时找到.app实际运行的位置?
I've my javafx jar running inside a .app. Now if I execute
System.getProperty("user.dir")
I get location of user home i.e. /Users/DevAccount/ where DevAccount is system user name instead of location of .app file or .jar file.
How do I find where the .app is actually running from at runtime?
或者,请建议如何将java.library.path设置为a中的文件夹.app bundle。
Alternatively please suggest how to set java.library.path to a folder within a .app bundle.
注意:如果我在外面运行jar .app我可以根据需要设置java.library.path但是当运行.app,user.dir系统属性不返回所需的值。
Note: If I run jar outside .app I'm able to set java.library.path as desired but when .app is run, user.dir system property does not return desired value.
实际上javafxpackager默认设置java.library。 .app / Contents / Java的路径
Actually javafxpackager by default sets java.library.path to .app/Contents/Java
因此System.getProperty(java.library.path)本身可以提供所需的路径。
So System.getProperty("java.library.path") itself can give the required path.
PS:@SO Admins,对于我的大部分问题都感到很失望。我做错了吗?
P.S.: @SO Admins, Surprised to see lack of response for most of my questions. Am I doing something wrong?