我正在尝试部署 JavaFX 应用程序。我一直在开发的应用程序相当复杂,包括几个库。当我创建一个 jnlp 并尝试运行它时,我总是收到“运行时错误。单击以获取详细信息”消息。有人建议我尝试只做一个简单的 Hello World 应用程序,看看它是否是包含的库的问题。我试过了,但我仍然收到“运行时错误”。
这是我正在尝试使用的 build.xml。
<project name="App" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpath="C:\Program Files\Java\jdk7\lib\ant-javafx.jar" />
<target name="default">
<fx:deploy width="600" height="400" outdir="${basedir}/dist" outfile="App">
<fx:application name="App" mainClass="${javafx.main.class}"/>
<fx:resources>
<!-- include application jars -->
<fx:fileset dir="${basedir}" includes="*.jar"/>
<fx:fileset dir="${basedir}/lib" includes="*.jar"/>
<fx:fileset dir="${basedir}" includes="app.ini" />
<fx:fileset dir="${basedir}/template" includes="*.template" />
</fx:resources>
<!-- request user level installation -->
<fx:preferences install="false"/>
</fx:deploy>
</target>
</project>
对于 Hello World 版本,我刚刚删除了该<fx:resources>
部分。我从 Eclipse 内部将它们都作为 ant 任务运行。他们都在我的项目中使用 .jnlp 和 .html 文件创建了一个 dist 文件夹。然后我单击 jnlp 运行应用程序并看到一个小窗口,其中包含文本“运行时错误。单击以获取详细信息。” 我单击它并得到一个错误窗口,上面写着“应用程序无法运行。执行应用程序时出错。单击“详细信息”以获取更多信息。”我单击“详细信息”按钮并看到带有以下信息的 Java 控制台(HelloWorld 版本):
Java Plug-in 10.7.2.11
Using JRE version 1.7.0_07-b11 Java HotSpot(TM) 64-Bit Server VM
User home directory = C:\Users\user
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
Match: beginTraversal
Match: digest selected JREDesc: JREDesc[version 1.6+, heap=-1--1, args=null, href=http://java.sun.com/products/autodl/j2se, sel=false, null, null], JREInfo: JREInfo for index 0:
platform is: 1.7
product is: 1.7.0_07
location is: http://java.sun.com/products/autodl/j2se
path is: C:\Program Files\Java\jre7\bin\javaw.exe
args is: null
native platform is: Windows, amd64 [ x86_64, 64bit ]
JavaFX runtime is: JavaFX 2.2.1 found at C:\Program Files\Java\jre7\
enabled is: true
registered is: true
system is: true
Match: ignoring maxHeap: -1
Match: ignoring InitHeap: -1
Match: digesting vmargs: null
Match: digested vmargs: [JVMParameters: isSecure: true, args: ]
Match: JVM args after accumulation: [JVMParameters: isSecure: true, args: ]
Match: digest LaunchDesc: file:/G:/workspaces/JavaProjects/JavaFXHelloWorld/dist/HelloWorld.jnlp
Match: digest properties: []
Match: JVM args: [JVMParameters: isSecure: true, args: ]
Match: endTraversal ..
Match: JVM args final:
Match: Running JREInfo Version match: 1.7.0.07 == 1.7.0.07
Match: Running JVM args match: have:<> satisfy want:<>
CacheEntry[file:/G:/workspaces/JavaProjects/JavaFXHelloWorld/dist/HelloWorld.jnlp]: updateAvailable=false,lastModified=Fri Sep 14 07:13:28 MDT 2012,length=915
当我运行我正在处理的应用程序时,我得到一个几乎相同的错误。我刚刚卸载了java,然后重新安装了最新的SDK。除了可能应用程序使用 64 位 JVM 而不是我安装的 32 位 JVM 之外,这并没有做任何事情。错误消息保持不变。
有谁知道我做错了什么?我的构建脚本不正确吗?有没有更好的部署方式?我不必拥有 jnlp,因此我对任何部署方法都持开放态度。我只需要可以在 Windows 机器上运行的东西,也可能是在 Mac 上运行的东西。
我试过用谷歌搜索我的问题,我搜索了 StackOverflow,似乎找不到任何相关的东西。我可能只是使用了错误的搜索词。
任何帮助将不胜感激。
谢谢,哈代