Spiff
Spiff

Reputation: 4104

JFXPanel security exception

I updated to 1.7.0_67-b01 and now it seems I can't embed a JavaFX panel in my swing application. This is the exception I get. Anyone knows a workaround?

java.security.AccessControlException: access denied ("java.util.PropertyPermission" "javafx.macosx.embedded" "write")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.System.setProperty(Unknown Source)
    at javafx.embed.swing.JFXPanel$1.run(Unknown Source)
    at javafx.embed.swing.JFXPanel$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.embed.swing.JFXPanel.initFx(Unknown Source)
    at javafx.embed.swing.JFXPanel.<init>(Unknown Source)
    at webview.WebBrowserFX.<init>(WebBrowserFX.java:38)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at baf.ui.WebView.initializeFXWebView(Unknown Source)
    at baf.ui.WebView.<init>(Unknown Source)
    at mypackage.MyClass.<init>(Unknown Source)

Upvotes: 0

Views: 180

Answers (2)

Dmitry Ginzburg
Dmitry Ginzburg

Reputation: 7461

You should modify your policy file ($JAVA_HOME/jre/lib/security/javaws.policy) to include permissions to write this property. So, you should add this line to javaws.policy:

permission java.util.PropertyPermission "javafx.macosx.embedded", "write";

It seems to be the old bug

Upvotes: 1

Spiff
Spiff

Reputation: 4104

I tried what's suggested in this post and it works.

I add the permission programmatically.

PropertyPermission propertyPermission = new PropertyPermission("javafx.macosx.embedded", "write");

However the permissions of the orginal policy are lost.

Upvotes: 0

Related Questions