简体   繁体   English

使用Java Web Start启动JavaFX 2.2应用程序时出错

[英]Error when launching JavaFX 2.2 Application with Java Web Start

I developed a JavaFX 2.2 application. 我开发了一个JavaFX 2.2应用程序。 I packaged and signed the JAR and wrote the JNLP by hand (see below). 我打包并签署了JAR并手工编写了JNLP(见下文)。

The Problem is, that i can't start the application with Java Web Start; 问题是,我无法使用Java Web Start启动应用程序; for example by double-clicking the .jnlp-file. 例如,双击.jnlp文件。

I'm facing the following error message: Unable to find class: xxxx.pamoja.client.RichClientApplication 我面临以下错误消息: 无法找到类: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. 或者双击JAR文件。

Therefore, i know that the application works in general. 因此,我知道该应用程序的工作原理。 So i guess the problem is related to Java Web Start. 所以我猜这个问题与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看起来像这样:

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: 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的:

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 UPDATE

I added the codebase attribute as following: 我添加了codebase属性如下:

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

And JavaFX as resource: 和JavaFX作为资源:

<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. 错误消息无法找到类:xxxx.pamoja.client.RichClientApplication消失了。 But now it throws the following NullPointerException: 但现在它抛出以下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)

Your JNLP file is invalid. 您的JNLP文件无效。 Have a look at the Oracle reference for the JNLP file format: JNLP File Syntax 查看JNLP文件格式的Oracle参考: JNLP文件语法

The error I can directly spot is the missing codebase attribute in your JNLP tag. 我可以直接发现的错误是JNLP标记中缺少的codebase属性。

Your jnlp does not look correct. 你的jnlp看起来不正确。 And you need to add a reference to JavaFX - for example for Windows: 您需要添加对JavaFX的引用 - 例如对于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>

不要手动生成jnlp,而是使用JavaFX打包工具自动生成jnlp ,一旦工作,你可以根据需要手动调整jnlp。

I solved my problem! 我解决了我的问题! Two things were necessary: 有两件事是必要的:

  1. the codebase attribute. codebase属性。

  2. the < jfx:javafx-desc > tag to specify the class which implements the JavaFX application class. <jfx:javafx-desc>标记用于指定实现JavaFX应用程序类的类。 Java Web Start can start the JavaFX application straightly without a special 'launcher' Main class. Java Web Start可以直接启动JavaFX应用程序而无需特殊的“启动器”主类。

The final JNLP: 最终的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. 如果不将JavaFX运行时指定为资源,我不知道它是否正常工作。 Maybe it fails with older Java version. 也许它在较旧的Java版本中失败了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM