Exception in Launch4j

夙愿已清 提交于 2019-12-03 11:16:17

Show your installerLaunch4j.xml config please. I my case problem was in wrong icon format (I was used png instead ico).

The documentation for Launch4j says to do it this way:

<property name="launch4j.dir" location="< your launch4j directory >" />

<taskdef name="launch4j"
    classname="net.sf.launch4j.ant.Launch4jTask"
    classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar" />

<launch4j configFile="./l4j/yourLaunch4jSpecFile.xml" />

I have used this method for years with no trouble. FWIW, my path includes "Program Files" with a space, which has created no problems.

I've had problems running such tools when there were spaces in the paths. Can you try running everything from paths that have no spaces in them?

I had the same exception being reported, when I tried to use the Ant task for Launch4j. While invoking it with an external XML config file worked flawlessly, invoking it using the <config> element did not work.

I created the entire configuration inside my Ant build XML based on the external Launch4j config file, used trial and error to determine what should be specified as an attribute and what as an element hierarchy to the Ant task. While doing this, I also specified all empty string values from the XML, such as errTitle="" and cmdLine="" attributes. DO NOT DO THIS. Simply omit those.

An example based on my working project:

<target name="launch4j-wrap" depends="init">
    <property name="launch4j.dir" location="C:/Program Files (x86)/Launch4j" />
    <property name="temp.install.dir.name" value="ExampleApp_installDir"/>
    <property name="temp.install.dir" value="${dist.dir}/${temp.install.dir.name}/bin" />
    <property name="prod.version" value="1.0.0.0"/>
    <property name="prod.copyright" value="2010-2015"/>

    <taskdef name="launch4j"
             classname="net.sf.launch4j.ant.Launch4jTask"
             classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar" />

    <launch4j>
        <config headerType="gui" outfile="${temp.install.dir}/ExampleApp.exe"
                dontWrapJar="false" jarPath="${temp.install.dir}/ExampleApp.jar"
                chdir="." priority="normal"
                downloadUrl="http://java.com/download"
                stayAlive="false" restartOnCrash="false"
                icon="path/to/ExampleApp.ico">
            <classPath mainClass="org.example.ExampleApp">
                <cp>some-jar.jar</cp>
                <cp>some-other-jar.jar</cp>
                <!-- ... -->
            </classPath>
            <jre bundledJre64Bit="false" bundledJreAsFallback="false"
                 minVersion="1.7.0" maxVersion="" jdkPreference="preferJre"
                 runtimeBits="64/32" maxHeapSize="1024" />
            <versionInfo productVersion="${prod.version}"
                         txtProductVersion="${prod.version}"
                         fileVersion="${prod.version}"
                         txtFileVersion="${prod.version}"
                         copyright="${prod.copyright}"
                         fileDescription="Launches Example App"
                         productName="Example App"
                         companyName="Example Inc."
                         internalName="Flawless Unicorn"
                         originalFilename="ExampleApp.exe" />
        </config>
    </launch4j>

    <!--
    <launch4j configFile="path/to/my/external-config.xml" />
    -->

</target>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!