在mac os x上的.app内运行时获取jar的路径 [英] Obtain path of jar when running inside a .app on mac os x

查看:252
本文介绍了在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?

这篇关于在mac os x上的.app内运行时获取jar的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆