0

我正在尝试从通过 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 中获取主文件夹?

4

1 回答 1

1

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

<security>
    <all-permissions/>
</security>
于 2012-09-26T17:04:05.270 回答