2011-06-09 195 views
11

我在我的build.xml中有以下說明,並且出現以下異常。在Launch4j中的例外

launch4j:net.sf.launch4j.ExecException:執行失敗(1):C:\程序 文件\ Launch4j \ BIN \ windres.exe --preprocessor =鍵入-J RC -O COFF -F PE-I386 C:\ WINDOWS \ TEMP \ launch4j2603642297702639520rc C:\ WINDOWS \ TEMP \ launch4j1179691608441365102o

這是我的構建腳本:

<project basedir="." default="build" name="Bienvenue"> 
    <!-- Crée le fichier d'installation BienvenueSetup.exe --> 
    <target name="build"> 
    <!-- Création du dossier classes --> 
    <mkdir dir="classes"/> 

    <!-- Compilation des classes du programme --> 
    <javac srcdir="src" destdir="classes" /> 

    <!-- Création du dossier install/lib --> 
    <mkdir dir="install/lib"/> 

    <!-- Création du fichier Bienvenue.jar --> 
    <jar destfile="install/lib/Bienvenue.jar" basedir="classes"/> 

    <!-- Suppression du dossier classes --> 
    <delete dir="classes"/> 

    <!-- Copie du JRE dans le dossier install/jre6 en excluant les fichiers 
    inutiles mentionnés dans le fichier README.TXT du JRE 
    (attention il faut garder le fichier bin/javaw.exe du JRE) --> 
    <copy todir="install/jre6"> 
    <fileset dir="C:\Program Files\Java\jre6"> 
    <include name="*"/> 
    <include name="bin/**"/> 
    <include name="lib/**"/> 
    <exclude name="lib/charsets.jar"/> 
    <exclude name="lib/ext/sunjce_provider.jar"/> 
    <exclude name="bin/rmid.exe"/> 
    <exclude name="bin/rmiregistry.exe"/> 
    <exclude name="bin/tnameserv.exe"/> 
    <exclude name="bin/keytool.exe"/> 
    <exclude name="bin/kinit.exe"/> 
    <exclude name="bin/klist.exe"/> 
    <exclude name="bin/ktab.exe"/> 
    <exclude name="bin/policytool.exe"/> 
    <exclude name="bin/orbd.exe"/> 
    <exclude name="bin/servertool.exe"/> 
    <exclude name="bin/java.exe"/> 
    <exclude name="bin/javaws.exe"/> 
    <exclude name="bin/javacpl.exe"/> 
    <exclude name="bin/jucheck.exe"/> 
    <exclude name="bin/jusched.exe"/> 
    <exclude name="bin/wsdetect.dll"/> 
    <exclude name="bin/npjava*.dll"/> 
    <exclude name="bin/npoji610.dll"/> 
    <exclude name="bin/regutils.dll"/> 
    <exclude name="bin/axbridge.dll"/> 
    <exclude name="bin/deploy.dll"/> 
    <exclude name="bin/jpicom.dll"/> 
    <exclude name="bin/javacpl.cpl"/> 
    <exclude name="bin/jpiexp.dll"/> 
    <exclude name="bin/jpinscp.dll"/> 
    <exclude name="bin/jpioji.dll"/> 
    <exclude name="bin/jpishare.dll"/> 
    <exclude name="lib/deploy.jar"/> 
    <exclude name="lib/plugin.jar"/> 
    <exclude name="lib/deploy/messages*.properties"/> 
    <exclude name="lib/deploy/splash.jpg"/> 
    </fileset> 
    </copy > 

    <!-- Création du fichier Bienvenue.exe avec Launch4j --> 
    <exec executable="C:\Program Files\Launch4j\launch4jc.exe"> 
    <arg value="${basedir}\installerLaunch4j.xml"/> 
    </exec > 

    <!-- Création du fichier BienvenueSetup.exe avec Inno Setup --> 
    <exec executable="C:\Program Files\Inno Setup 5\ISCC.exe"> 
    <arg value="${basedir}\installerInnoSetup.iss"/> 
    </exec > 

    <!-- Suppression du dossier install --> 
    <delete dir="install/"/> 

    <echo message="BienvenueSetup.exe ready"/> 
    </target > 
    </project > 

誰能幫我找出我在做什麼錯?

+0

有什麼異常? – Dave 2011-06-09 13:32:59

+0

launch4j:net.sf.launch4j.ExecException:Exec失敗(1):C:\ Program Files \ Launch4j \ bin \ windres.exe --preprocessor = type -J rc -O coff -F pe-i386 C:\ Windows \ TEMP \ launch4j2603642297702639520rc C:\ Windows \ TEMP \ launch4j1179691608441365102o – Manikandan 2011-06-09 13:34:40

+0

什麼操作系統以及您以什麼用戶登錄爲 – Woot4Moo 2011-06-09 13:45:59

回答

3

documentation for Launch4j說,做到這一點是這樣的:

<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" /> 

我已經使用這個方法多年,沒有麻煩。 FWIW,我的路徑包括帶有空格的「程序文件」,這沒有產生任何問題。

1

當路徑中存在空格時,我遇到了運行此類工具的問題。你可以嘗試運行一些沒有空格的路徑嗎?

6

請給出你的installerLaunch4j.xml配置。我的案例問題是錯誤的圖標格式(我用png而不是ico)。

+0

是的,將圖標從格式png更改爲ico,解決它,異常日誌是:net.sf.launch4j.ExecException:Exec失敗(1):C:\ Maven_repository \ net \ sf \ launch4j \ launch4j \ 3.8.0 \ launch4j-3.8.0-workdir-win32 \ bin \ windres.exe --preprocessor = type -J rc -O coff -F pe-i386 C:\ Users \ ahu \ AppData \ Local \ Temp \ launch4j4966396877810588589rc C:\ Users \ ahu \ AppData \ Local \ Temp \ launch4j464671497321610327o \t at net.sf.launch4j.Util.exec(Util.java:156) \t at net。sf.launch4j.Cmd.exec(Builder.java:212) \t at net.sf.launch4j.Builder.build(Builder.java:96) – 2016-06-30 00:57:34

0

當我嘗試使用Launch4j的Ant任務時,我報告了相同的異常。在用外部XML配置文件調用它時完美地工作,使用<config>元素調用它不起作用。

我在Ant構建XML內部基於外部Launch4j配置文件創建了整個配置,使用試驗和錯誤來確定應指定哪些屬性以及作爲Ant任務的元素層次結構。在執行此操作時,我還指定了XML中的所有空字符串值,如errTitle=""cmdLine=""屬性。不要這樣做。簡單地省略那些。

一個例子根據我的工作項目:

<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>