我已经开发了一个JavaFx应用程序,它运行得很好,没有任何问题。现在,我想从它构建一个MSI安装程序,并且我已经修改了build.fxbuild和build.xml。我也安装了WIX工具。当我作为ant构建运行build.xml时,它显示构建成功,但是发生了一些错误,并且没有生成MSI。
错误
Buildfile: D:\SmallExperiment\java fx\build\build.xml
setup-staging-area:
[delete] Deleting directory D:\SmallExperiment\java fx\build\externalLibs
[delete] Deleting directory D:\SmallExperiment\java fx\build\project
[delete] Deleting directory D:\SmallExperiment\java fx\build\projectRefs
[mkdir] Created dir: D:\SmallExperiment\java fx\build\externalLibs
[copy] Copying 1 file to D:\SmallExperiment\java fx\build\externalLibs
[copy] Copying 1 file to D:\SmallExperiment\java fx\build\externalLibs
[copy] Copying 1 file to D:\SmallExperiment\java fx\build\externalLibs
[copy] Copying 1 file to D:\SmallExperiment\java fx\build\externalLibs
[mkdir] Created dir: D:\SmallExperiment\java fx\build\project
[copy] Copying 17 files to D:\SmallExperiment\java fx\build\project
[mkdir] Created dir: D:\SmallExperiment\java fx\build\projectRefs
do-compile:
[delete] Deleting directory D:\SmallExperiment\java fx\build\build
[mkdir] Created dir: D:\SmallExperiment\java fx\build\build\src
[mkdir] Created dir: D:\SmallExperiment\java fx\build\build\libs
[mkdir] Created dir: D:\SmallExperiment\java fx\build\build\classes
[copy] Copying 4 files to D:\SmallExperiment\java fx\build\build\libs
[copy] Copying 17 files to D:\SmallExperiment\java fx\build\build\src
[javac] Compiling 10 source files to D:\SmallExperiment\java fx\build\build\classes
[copy] Copying 7 files to D:\SmallExperiment\java fx\build\build\classes
init-fx-tasks:
do-deploy:
[copy] Copying 4 files to D:\SmallExperiment\java fx\build\dist\libs
[mkdir] Created dir: D:\SmallExperiment\java fx\build\build\classes\META-INF
Using base JDK at: C:\Program Files\Java\jdk1.8.0_201\jre
Using base JDK at: C:\Program Files\Java\jdk1.8.0_201\jre
Bundler MSI Installer skipped because of a configuration problem: Can not find WiX tools (light.exe, candle.exe).
Advice to fix: Download WiX 3.0 or later from http://wix.sf.net and add it to the PATH.
BUILD SUCCESSFUL
Total time: 5 seconds
虽然我已经在环境路径中包含了WIX,但是上面的错误还是发生了。
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="java fx" default="do-deploy" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<target name="init-fx-tasks">
<path id="fxant">
<filelist>
<file name="${java.home}\..\lib\ant-javafx.jar"/>
<file name="${java.home}\lib\jfxrt.jar"/>
</filelist>
</path>
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpathref="fxant"/>
</target>
<target name="setup-staging-area">
<delete dir="externalLibs" />
<delete dir="project" />
<delete dir="projectRefs" />
<mkdir dir="externalLibs" />
<copy todir="externalLibs">
<fileset dir="D:\SmallExperiment\java fx\lib">
<filename name="jfxrt.jar"/>
</fileset>
</copy>
<copy todir="externalLibs">
<fileset dir="D:\SmallExperiment\java fx\lib">
<filename name="postgresql-42.2.5.jar"/>
</fileset>
</copy>
<copy todir="externalLibs">
<fileset dir="D:\SmallExperiment\java fx\lib">
<filename name="mssql-jdbc-7.2.1.jre8.jar"/>
</fileset>
</copy>
<copy todir="externalLibs">
<fileset dir="D:\SmallExperiment\java fx\lib">
<filename name="rt.jar"/>
</fileset>
</copy>
<mkdir dir="project" />
<copy todir="project">
<fileset dir="D:\SmallExperiment\java fx">
<include name="src/**" />
</fileset>
</copy>
<mkdir dir="projectRefs" />
</target>
<target name='do-compile'>
<delete dir="build" />
<mkdir dir="build/src" />
<mkdir dir="build/libs" />
<mkdir dir="build/classes" />
<!-- Copy project-libs references -->
<copy todir="build/libs">
<fileset dir="externalLibs">
<include name="jfxrt.jar"/>
<include name="postgresql-42.2.5.jar"/>
<include name="mssql-jdbc-7.2.1.jre8.jar"/>
<include name="rt.jar"/>
</fileset>
</copy>
<!-- Copy project references -->
<!-- Copy project sources itself -->
<copy todir="build/src">
<fileset dir="project/src">
<include name="**/*"/>
</fileset>
</copy>
<javac includeantruntime="true" source="1.8" target="1.8" srcdir="build/src" destdir="build/classes" encoding="Cp1252">
<classpath>
<fileset dir="build/libs">
<include name="*"/>
</fileset>
</classpath>
</javac>
<!-- Copy over none Java-Files -->
<copy todir="build/classes">
<fileset dir="project/src">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="do-deploy" depends="setup-staging-area, do-compile, init-fx-tasks">
<delete file="dist"/>
<delete file="deploy" />
<mkdir dir="dist" />
<mkdir dir="dist/libs" />
<copy todir="dist/libs">
<fileset dir="externalLibs">
<include name="*" />
</fileset>
</copy>
<fx:resources id="appRes">
<fx:fileset dir="dist" includes="java fx.jar"/>
<fx:fileset dir="dist" includes="libs/*"/>
</fx:resources>
<fx:application id="fxApplication"
name="ConfOfApp"
mainClass="application.Main"
/>
<mkdir dir="build/classes/META-INF" />
<fx:jar destfile="dist/java fx.jar">
<fx:application refid="fxApplication"/>
<fileset dir="build/classes">
</fileset>
<fx:resources refid="appRes"/>
<manifest>
<attribute name="Implementation-Vendor" value="com.ankur"/>
<attribute name="Implementation-Title" value="ConfOfApp"/>
<attribute name="Implementation-Version" value="1.0.2"/>
<attribute name="JavaFX-Feature-Proxy" value="None"/>
</manifest>
</fx:jar>
<mkdir dir="deploy" />
<!-- Need to use ${basedir} because somehow the ant task is calculating the directory differently -->
<fx:deploy
embedJNLP="false"
extension="false"
includeDT="false"
offlineAllowed="true"
outdir="${basedir}/deploy"
outfile="java fx" nativeBundles="msi"
updatemode="background" >
<fx:platform basedir="${java.home}"/>
<fx:info title="java fx" vendor="com.ankur"/>
<fx:application refId="fxApplication"/>
<fx:resources refid="appRes"/>
</fx:deploy>
</target>
</project>
发布于 2019-11-13 03:19:54
为此正在开发一种新的工具: jpackage
如果您的项目可以移植到Gradle,那么您可以很容易地使用Badass jlink plugin:https://github.com/beryx/badass-jlink-plugin来使用jpackage和捆绑的JVM来构建安装程序/包
这里有一篇文章,介绍了如何使用OpenJDK 11和OpenJDK 14以及jpackage来构建应用程序镜像,只用于构建安装程序/包:https://walczak.it/blog/distributing-javafx-desktop-applications-without-requiring-jvm-using-jlink-and-jpackage
https://stackoverflow.com/questions/55926766
复制相似问题