1

首先,我的 jar 文件工作正常,但每次我尝试启动 .jnlp 时都会出现运行时异常,这

CacheEntry[file:/C:/Users/Erick/Documents/GitHub/TarotBuddyOnline/out/artifacts/JavaFXApp/JavaFXApp.jnlp]: updateAvailable=true,lastModified=Thu Oct 03 16:41:19 EDT 2013,length=965

我正在使用生成的 .jnlp,即使我开始新项目并尝试使用 FXML 运行 Hello World,我也会收到相同的错误。

在我添加之前

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

我收到了这个错误

CacheEntry[file:/C:/Users/Erick/Documents/GitHub/TarotBuddyOnline/out/artifacts/JavaFXApp/JavaFXApp.jnlp]: updateAvailable=true,lastModified=Thu Oct 03 16:42:16 EDT 2013,length=1014
access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
file:/C:/Users/Erick/Documents/GitHub/TarotBuddyOnline/out/artifacts/JavaFXApp/JavaFXApp.jar!/sample/sample.fxml
  at java.security.AccessControlContext.checkPermission(Unknown Source)
  at java.security.AccessController.checkPermission(Unknown Source)
  at java.lang.SecurityManager.checkPermission(Unknown Source)
  at sun.plugin2.applet.FXAppletSecurityManager.checkPermission(Unknown Source)
  at java.lang.Class.checkMemberAccess(Unknown Source)
  at java.lang.Class.getDeclaredFields(Unknown Source)
  at sun.reflect.misc.FieldUtil.getDeclaredFields(Unknown Source)
  at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2543)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2155)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
  at sample.Main.start(Main.java:13)
  at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:132)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
  at java.lang.Thread.run(Unknown Source)

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at sun.plugin2.applet.FXAppletSecurityManager.checkPermission(Unknown Source)
    at java.lang.Class.checkMemberAccess(Unknown Source)
    at java.lang.Class.getDeclaredFields(Unknown Source)
    at sun.reflect.misc.FieldUtil.getDeclaredFields(Unknown Source)
    at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2543)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2155)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
    at sample.Main.start(Main.java:13)
    at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:132)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
    at java.lang.Thread.run(Unknown Source)
Exception in runnable
java.lang.RuntimeException: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
    at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:148)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at sun.plugin2.applet.FXAppletSecurityManager.checkPermission(Unknown Source)
    at java.lang.Class.checkMemberAccess(Unknown Source)
    at java.lang.Class.getDeclaredFields(Unknown Source)
    at sun.reflect.misc.FieldUtil.getDeclaredFields(Unknown Source)
    at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2543)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2155)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
    at sample.Main.start(Main.java:13)
    at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:132)
    ... 8 more
CacheEntry[file:/C:/Users/Erick/Documents/GitHub/TarotBuddyOnline/out/artifacts/JavaFXApp/JavaFXApp.jar]: updateAvailable=false,lastModified=Thu Oct 03 16:41:19 EDT 2013,length=18203

这是jnlp,

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="JavaFXApp.jnlp">
  <information>
    <title>Sample JavaFX Application</title>
    <vendor>Unknown vendor</vendor>
    <description>Sample JavaFX 2.0 application.</description>
    <offline-allowed/>
  </information>
  <resources>
    <jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
  </resources>
  <resources>
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="JavaFXApp.jar" size="18203" download="eager" />
  </resources>

  <applet-desc  width="600" height="400" main-class="com.javafx.main.NoJavaFXFallback"  name="JavaFXApp" >
    <param name="requiredFXVersion" value="2.2+"/>
  </applet-desc>
  <jfx:javafx-desc  width="600" height="400" main-class="sample.Main"  name="JavaFXApp" />
  <update check="background"/>
</jnlp>

我试图让它在网站上运行顺便说一句,我做错了什么?

4

1 回答 1

1

使用 JavaFX 2.2,您需要对您的应用程序进行签名才能在浏览器中使用 FXML。

JavaFX 2.2 FXMLLoader 在内部使用反射来执行它的工作——这在提供给嵌入网页的未签名沙盒应用程序的特权中不起作用。

于 2013-10-04T05:23:36.753 回答