Question

I developed a JavaFX 2.2 application. I packaged and signed the JAR and wrote the JNLP by hand (see below).

The Problem is, that i can't start the application with Java Web Start; for example by double-clicking the .jnlp-file.

I'm facing the following error message: Unable to find class: xxxx.pamoja.client.RichClientApplication

It is no problem to start the application with:

java -jar pamoja-rich-client.jar

or by double-clicking the JAR file.

Therefore, i know that the application works in general. So i guess the problem is related to Java Web Start.

I spent a lot of time "googling around" but didn't find any information applicable to my problem.

Has someone an idea? I'm grateful for any hints!

The JAR looks like this:

jar
 |- META-INF
 |     |- MANIFEST.MF
 |     |- PAMOJA.RSA
 |     |- PAMOJA.SF
 |
 |- com
     |- javafx
     |    |- main
     |        |- Main.class
     |        |- NoJavaFXFallback.class
     |
     |- xxxxx
          |- pamoja
                |- client
                      |- RichClientApplication.class
                      |- main.css
                      |- main.fxml
                      |- ...

The Manifest (before signing):

Manifest-Version: 1.0
JavaFX-Version: 2.2
JavaFX-Application-Class: xxxx.pamoja.client.RichClientApplication
JavaFX-Fallback-Class: com.javafx.main.NoJavaFXFallback
Main-Class: com.javafx.main.Main

The JNLP:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="pamoja-rich-client.jnlp">
<information>
    <title>Pamoja Rich Client</title>
    <vendor>kKdH</vendor>
    <description></description>
    <icon href="icon.png"/>
</information>
<resources>
    <j2se version="1.7+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="pamoja-rich-client.jar" download="eager" main="true"/>
</resources>
<security>
    <all-permissions/>
</security>
<application-desc name="Pamoja Rich Client"/>
<update check="always" policy="prompt-run"/>
</jnlp>

Java:

java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode, sharing)

UPDATE

I added the codebase attribute as following:

<jnlp spec="1.0+" href="pamoja-rich-client.jnlp" codebase="http://localhost:8080/">

And JavaFX as resource:

<resources os="Windows">
    <jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
</resources>

The error message Unable to find class: xxxx.pamoja.client.RichClientApplication is gone. But now it throws the following NullPointerException:

java.lang.NullPointerException
at com.javafx.main.Main.getAppArguments(Main.java:506)
at com.javafx.main.Main.main(Main.java:860)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Was it helpful?

Solution 4

I solved my problem! Two things were necessary:

  1. the codebase attribute.

  2. the < jfx:javafx-desc > tag to specify the class which implements the JavaFX application class. Java Web Start can start the JavaFX application straightly without a special 'launcher' Main class.

The final JNLP:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="pamoja-rich-client.jnlp" codebase="http://localhost:8080/">
    <information>
        <title>Pamoja Rich Client</title>
        <vendor>kKdH</vendor>
        <description></description>
        <icon href="icon.png"/>
    </information>
    <resources>
        <j2se version="1.7+" href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="pamoja-rich-client.jar"/>
    </resources>
    <security>
        <all-permissions/>
    </security>
    <application-desc name="Pamoja Rich Client"/>
    <jfx:javafx-desc  main-class="xxxx.pamoja.client.RichClientApplication" name="RichClientApplication" />
    <update check="always" policy="prompt-run"/>
</jnlp>

I don't know whether it works in general without specifying the JavaFX runtime as resource. Maybe it fails with older Java version.

OTHER TIPS

Your JNLP file is invalid. Have a look at the Oracle reference for the JNLP file format: JNLP File Syntax

The error I can directly spot is the missing codebase attribute in your JNLP tag.

Your jnlp does not look correct. And you need to add a reference to JavaFX - for example for Windows:

<resources os="Windows">
    <jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
</resources>

Don't manually generate the jnlp, instead use the JavaFX packaging tools to automatically generate the jnlp and, once that works, you can manually tweak the jnlp if you wish.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top