我正在尝试从通过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获取主文件夹?
答案 0 :(得分:1)
尝试将以下内容添加到JNLP文件
<security>
<all-permissions/>
</security>