当前位置: 首页 > 知识库问答 >
问题:

经过签名的Javafx jar工作并执行,但是jnlp对Javafx jar的引用找不到对gui.fxml文件的引用

景鹏飞
2023-03-14

我试图将一个javafx应用程序嵌入到一个项目的网页中。我已经成功导出并执行了这个javafx jar文件。该文件作为可执行jar文件从eclipse导出,然后部署应用程序来创建html、jnlp和我的jar文件的副本。

我签署了我的jar,验证它是签名的,然后打开Chrome中的html文件。javafx应用程序试图加载,但出现了以下错误:

    java.lang.NullPointerException: Location is required.
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at application.Main.start(Main.java:19)
    at com.sun.javafx.applet.FXApplet2$2.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$45/5729401.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$44/8383735.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$$Lambda$34/14272056.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.NullPointerException: Location is required.
    at com.sun.javafx.applet.FXApplet2$2.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$45/5729401.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$44/8383735.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$$Lambda$34/14272056.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Location is required.
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
    at javafx.fxml.FXMLLoader.load(Unknown Source)
    at application.Main.start(Main.java:19)
    ... 11 more
CacheEntry[file:/C:/Users/tso5912/Desktop/WebDriverEmbed/webDriverDeploy/webdriverjar2.jar]: updateAvailable=true,lastModified=Fri May 22 10:21:49 CDT 2015,length=107020288

Main.java:19在代码的主应用程序中指定了这一行:

package application;

import java.io.IOException;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application
{
    @Override
    public void start(Stage primaryStage)
    {
        Parent root;
        try
        {
            root = FXMLLoader.load(this.getClass().getResource("Gui.fxml"));
        }
        catch (IOException e)
        {
            e.printStackTrace();
            return;
        }

        Scene scene = new Scene(root);
        scene.getStylesheets().add(this.getClass().getResource("application.css").toExternalForm());
        primaryStage.setScene(scene);
        primaryStage.sizeToScene();
        primaryStage.show();
        primaryStage.setResizable(true);
        primaryStage.setTitle("WebDriver");

    }

    public static void main(String[] args)
    {
        launch(args);
    }
}

这是我的jnlp文件:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="WebDriver.jnlp">
  <information>
    <title>Sample JavaFX Application</title>
    <vendor>Unknown vendor</vendor>
    <description>Sample JavaFX 2.0 application.</description>
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="webdriverjar.jar" size="31252632" download="eager" />
  </resources>
  <jfx:javafx-desc  width="200" height="200" main-class="application.Main"  name="WebDriver" />
  <update check="background"/>
</jnlp>

任何帮助都很感激。

共有1个答案

钱俊楚
2023-03-14

我相信,您需要密切关注实际的Apache服务器(或类似服务器),以便正确编译JNLP。尝试在服务器上托管该文件,而不是从桌面上运行该文件,看看是否有帮助。

 类似资料:
  • 我正在关注关于Java的JavaFX入门指南https://openjfx.io/openjfx-docs/ 我在Eclipse上有一个基本的JavaFX项目,运行完美。现在我想从这个项目中生成一个可执行文件,在视窗、苹果电脑和Linux上(为了制作我自己的教程)。 代码由OpenJFX. io提供:https://github.com/openjfx/samples/tree/master/ID

  • 我从spring站点(https://spring.io/guides/gs/acture-service)下载了这个示例,我遵循了相同的步骤,但是如果我调用这个URL 显示http://localhost:9000/Health spring启动错误页 Spring启动版本是1.4.1,应该是{“status”:“up”},有什么建议吗? POM文件 日志:

  • 我有一个信任SP的ADFS。 我为我的信赖方信任添加了签名验证证书,但我收到以下错误: MSIS7093:MSIS7093:消息未使用预期签名算法签名。消息使用签名算法http://www.w3.org/2000/09/xmldsig#rsa-sha1.预期签名算法http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 这看起来很清楚,但与实际上下文不一

  • 问题内容: 我收到此错误消息: 错误:找到对集合的共享引用:Person.relatedPersons 当我尝试执行时: 我的网域: 知道为什么会这样吗? 问题答案: 当您尝试持久保存多个共享 同一 集合引用的实体实例(即与集合相等性相反的集合标识)时,Hibernate会显示此错误。 请注意,这意味着同样的 集合 ,而不是集合元素- 换句话说,在两个和必须相同。也许您是在实体加载后重置该集合?或

  • 我在没有得到标题中提到的错误的情况下成功调度作业时遇到了一些麻烦,具体来说: 下面是代码的一部分。。。其中,一切似乎都应该是好的。 运行作业方法。。。需要注意的主要问题是,它在以下行中失败: 方法,我认为它可能会引起问题...但是我不知道为什么。 任何帮助都将不胜感激。

  • 我在一个函数中创建了新的线程,其中包括pthread。h、 但它不起作用,编译时我不断收到以下错误: 未定义对“pthread\u create”的引用 我用来编译的标志如下: CFLAGS=-std=gnu99-pthread-g-Wall-Wextra-Werror-Wmissing声明-Wmissing原型-Werror隐式函数声明-Wreturn类型-Wparentheses-Wunuse