Obtain path of jar when running inside a .app on mac os x

依然范特西╮ 提交于 2019-12-11 11:39:13

问题


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?

Alternatively please suggest how to set java.library.path to a folder within a .app bundle.

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.


回答1:


Actually javafxpackager by default sets java.library.path to .app/Contents/Java

So System.getProperty("java.library.path") itself can give the required path.

P.S.: @SO Admins, Surprised to see lack of response for most of my questions. Am I doing something wrong?



来源:https://stackoverflow.com/questions/21331608/obtain-path-of-jar-when-running-inside-a-app-on-mac-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!