我正在将旧版Java应用程序更新为,使其可以与Java 8一起运行。我正在使用ant和JavaFX。这个程序需要一组参数。我已使用指定参数,并且它们出现在生成的cfg文件中,但是,通过单击图标启动应用程序时,不会对其进行处理。通过命令行启动应用程序时会处理参数。
ant脚本:
<project name="xxxxxx" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<property name="JAVA_HOME" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home"/>
<echo message="JAVA_HOME: ${JAVA_HOME}" />
<property name="build.src.dir" value="src"/>
<property name="build.classes.dir" value="classes"/>
<property name="build.dist.dir" value="dist"/>
<property name="build.java.resources.dir" value="../Contents/Java"/>
<target name="default">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath="${JAVA_HOME}/lib/ant-javafx.jar"/>
<fx:application id="xxxxxx" name="xxxxxx" mainClass="com.xxxx">
<fx:argument>-application com.xxxxx.Application -image xxxxxx/splashscreen.jpg -background black -title xxxxx -dock_icon ../application.icns -mem_max 1024</fx:argument>
</fx:application>
<fx:resources id="appRes">
<fx:fileset dir="${build.dist.dir}" includes="Startup.jar"/>
</fx:resources>
<fx:jar destfile="${build.dist.dir}/Startup.jar">
<fx:application refid="xxxxxxx"/>
<fx:resources refid="appRes"/>
<fx:fileset dir="${build.classes.dir}"/>
</fx:jar>
<fx:deploy width="300" height="250"
outdir="./deploy" embedJNLP="false"
outfile="xxxxxxx"
signBundle="false"
nativeBundles="all">
<fx:application refId="xxxx"/>
<fx:resources refid="appRes"/>
<fx:info title="xxxxx" vendor="xxx"/>
</fx:deploy>
</target>
</project>
生成的cfg:
[Application]
app.name=xxxxx
app.mainjar=Startup.jar
app.version=1.0
app.preferences.id=xxxx
app.mainclass=com/xxxx/SplashScreen
app.classpath=
app.runtime=$APPDIR/PlugIns/Java.runtime
app.identifier=xxxx
[JVMOptions]
[JVMUserOptions]
[ArgOptions]
-application com.xxx.Application -image com/xxx/splashscreen.jpg -background black -title xxxx -dock_icon ../application.icns -mem_max 1024
任何线索都值得赞赏。
答案 0 :(得分:1)
看起来每个参数都需要分别指定,如下所示:
<fx:argument>-application</fx:argument>
<fx:argument>com.xxxx.Application</fx:argument>
<fx:argument>-image</fx:argument>
<fx:argument>com/xxxx/splashscreen.jpg</fx:argument>