【问题标题】:getting user home folder from JWS signed jar从 JWS 签名的 jar 中获取用户主文件夹
【发布时间】:2012-09-26 10:52:21
【问题描述】:

我正在尝试从通过 JWS 启动的 jar 中获取用户主文件夹。 jar 已签名,我的 JNLP 有这样一行

<property name="homeFolder" value="@user.home" />

但我在尝试时:

System.getProperty("homeFolder");

我得到一个安全异常:

java.security.AccessControlException: access denied (java.util.PropertyPermission homeFolder read)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
    at java.security.AccessController.checkPermission(AccessController.java:546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)
    at java.lang.System.getProperty(System.java:667)
    at com.mimecast.searcher.jws.Main.main(Main.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.javaws.Launcher.executeApplication(Launcher.java:1919)
    at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1852)
    at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1614)
    at com.sun.javaws.Launcher.run(Launcher.java:139)
    at java.lang.Thread.run(Thread.java:680)

有没有办法从 JWS/JNLP 启动的 JAR 中获取主文件夹?

【问题讨论】:

    标签: java java-web-start securityexception home-directory getproperty


    【解决方案1】:

    尝试将以下内容添加到您的 JNLP 文件中

    <security>
        <all-permissions/>
    </security>
    

    【讨论】:

    • 谢谢利亚姆。我会接受这个答案,因为它解决了错误。我将打开一个新帖子,因为我还看不到值。
    猜你喜欢
    • 2010-11-01
    • 2012-02-16
    • 1970-01-01
    • 1970-01-01
    • 2012-01-21
    • 2013-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多