无法使用本机捆绑包 exe 启动 JavaFX 应用程序 [英] Failed to launch JavaFX application with native bundle exe

查看:33
本文介绍了无法使用本机捆绑包 exe 启动 JavaFX 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 JavaFX 应用程序,并使用 Ant 创建了它的本机包.当我尝试使用 Jar 从双击创建的包中启动应用程序时,它成功启动了我的应用程序.但是当我尝试双击 MyApplication.exe(比如说)时,它会抛出 JavaFX Launcher Error运行应用程序时出现异常".

I have created a JavaFX application, and created its native bundle using Ant. When I am trying to launch application using Jar from bundle created with double click, it successfully launching my application. But when I am trying double click on MyApplication.exe (say), it throwing JavaFX Launcher Error "Exception while running Application".

我已经比较了两个 jre,我发现有很多缺少的 jar、exe、dll 和一些属性文件.

I have compared both jre, there are many missing jar, exe, dll and some properties files I found.

我有这些环境设置 -

JAVA_HOME -- C:\Program Files\Java\jdk1.7.0_10
JREFX_HOME -- C:\Program Files\Oracle\JavaFX 2.2 Runtime
Path contains an entry of C:\Program Files\Java\jdk1.7.0_10\bin

JAVA_HOME 和 JREFX_HOME 和我的 build.xml 一样,用来取 ant-javafx.jar 和 jfxrt.jar --

JAVA_HOME and JREFX_HOME are used as in my build.xml to take ant-javafx.jar and jfxrt.jar --

${env.JAVA_HOME}/lib/ant-javafx.jar
${env.JREFX_HOME}/lib/jfxrt.jar

我创建捆绑包的步骤是 -

My steps to create bundle are -

<target name="CreatingExe" depends="SignedJar">
            <fx:deploy width="800" height="600" nativeBundles="all" outdir="${OutputPath}" outfile="${app.name}">
                <fx:info title="${app.title}"/>
                    <fx:application name="${app.title}" mainClass="${main.class}"/>
                    <fx:resources>
                        <fx:fileset dir="${OutputPath}" includes="*.jar"/>
                <fx:fileset dir="${WorkingFolder}/temp"/>
            </fx:resources>
         </fx:deploy>
 </target>

在 build.xml 中还需要什么才能使用 exe 正确启动应用程序?

What more needed in build.xml so that application launch correctly with exe ?

谢谢

推荐答案

通过将jre从"C:\Program Files\Java\jdk_version\jre"复制到JavaFx exe解决的问题\bundles\MyApplication\runtime\jre 在创建 exe 时的构建步骤中 -

The problem of not launching JavaFx exe resolved by copying jre from "C:\Program Files\Java\jdk_version\jre" to \bundles\MyApplication\runtime\jre in build steps upon creating exe as -

<target name="CopyJre" depends="CreatingExe"> 
 <delete dir="${app_path}/bundles/MyApplication/runtime/jre"/>
 <mkdir dir="${app_path}/bundles/MyApplication/runtime/jre"/>
 <copy todir=${app_path}/bundles/MyApplication/runtime/jre">
   <fileset dir="${env.JAVA_HOME}/jre" />
 </copy>
</target>

JAVA_HOME = C:\Program Files\Java\jdk_version

JAVA_HOME = C:\Program Files\Java\jdk_version

谢谢

这篇关于无法使用本机捆绑包 exe 启动 JavaFX 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆