The signed Javafx jar is up and running, but the jnlp link to the javafx jar cannot find the link to the Gui.fxml file

I am trying to embed a javafx application in a webpage for a project. I have successfully exported and executed this javafx jar file. The file was exported from eclipse as an executable jar file and then deployed the application to generate html, jnlp and a copy of my jar file.

I signed my jar, confirmed its subscription and then opened the html file in chrome. The javafx app tried to load but came up with this error:

    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 specifies this line in the main application of the code:

root = FXMLLoader.load (getClass (). getResource ("Gui.fxml"));

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);
    }
}

      

Project setup:

enter image description here

I also checked if the Gui.fxml file was located in the same folder as the Main.class file that was compiled into the jar file (switched the jar to zip and checked the zip content) and Gui. fxml were directly inside the applications folder.

I understand that the jnlp file cannot find the .fxml file, but I don’t know how to fix it, since the jar file is successfully executing itself already (which means the jar file finds the .fxml). All attempts to open the jar through the jnlp file end with the previous error (including using inline and webstart).

This is my jnlp file:

<?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>

      

Any help is appreciated.

+3


source to share


1 answer


For JNLP to compile properly, you need to be cared for on a real Apache server (or the like). Try hosting this on a server instead of just running the file from your desktop and see if that helps.



+2


source







All Articles