Domanda

I'm trying to get the user home folder from a jar launched via JWS. The jar is signed and my JNLP has a line like this

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

but I when trying:

System.getProperty("homeFolder");

I get a security exception:

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)

Is there any way of getting the home folder from a JWS/JNLP launched JAR?

È stato utile?

Soluzione

Try adding the following to your JNLP file

<security>
    <all-permissions/>
</security>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top