使用Preloader JavaFx将JAR文件捆绑到应用程序包中

时间:2015-05-11 20:42:16

标签: java ant package preloader

我尝试使用ant创建一个包含预加载器类的应用包。使用以下build.xml文件,可以成功创建应用程序。双击Viewer.app后,预加载器屏幕不会出现。当我使用java -jar Viewer.jar直接启动应用程序时,preloader屏幕可以在windows os和mac os上使用。

    

<taskdef name="bundleapp"
         classname="com.oracle.appbundler.AppBundlerTask"   
         classpath="classlib/appbundler-1.0.jar" />

<target name="bundle-MyProject">
    <bundleapp outputdirectory="dist"
        name="Viewer"
        displayname="MyProject Viewer"
        identifier="MyProject.Start"
        mainclassname="MyProject.Start"
        icon="classlib/MyProject.icns">

    <runtime dir="${env.JAVA_HOME}" />
    <classpath file="dist/Viewer.jar" />

    <classpath dir="dist/lib" includes="*.jar" />

    </bundleapp>
</target>

其他设置,例如preloaderClass =&#34; MyProject.Preloader&#34;不起作用。如何在App包中显示预加载器屏幕?我不需要任何其他软件包,如.exe .dmg或.msi文件。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我有解决方案

<?xml version="1.0" encoding="UTF-8"?>

<description>Create .app for test project.</description>

<target name="bundle-test">

    <taskdef    resource="com/sun/javafx/tools/ant/antlib.xml"
                uri="javafx:com.sun.javafx.tools.ant"
                classpath=".:${java.home}\..\lib\ant-javafx.jar"/>

    <fx:deploy  nativeBundles="all" width="600" height="600" outdir="outputdir">
        <info   title="Viewer" 
                vendor="My Company"
                description="Viewer Application"
                copyright="My Company ..."/>

        <fx:application 
                name="Viewer"
                mainClass="myapp.Start"
                preloaderClass="helpers.FirstPreloader">
            <fx:argument>ide=false</fx:argument>
            <fx:argument>app=true</fx:argument>
        </fx:application>

        <fx:platform basedir="${java.home}">
            <fx:jvmarg value="-Xms512m"/>
            <fx:jvmarg value="-Xmx1024m"/>
        </fx:platform>

        <fx:resources>
            <fx:fileset dir="dist">
                <include name="Viewer.jar"/>
                <include name="lib/*.jar"/>
            </fx:fileset>
        </fx:resources>

    </fx:deploy>

    <delete file="outputdir/null.html"/>
    <delete file="outputdir/null.jnlp"/>
    <delete file="outputdir/Viewer.jar"/>
    <delete file="outputdir/bundles/Viewer-1.0.dmg"/>
    <delete file="outputdir/bundles/Viewer-1.0.pkg"/>
    <delete dir="outputdir/lib"/>

</target>