12

I have the following instructions in my build.xml, and I am getting the following exception.

launch4j: net.sf.launch4j.ExecException: Exec failed (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

This is my build script:

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

Can anyone help me figure out what I am doing wrong?

Perception
  • 79,279
  • 19
  • 185
  • 195
Manikandan
  • 1,479
  • 6
  • 48
  • 89
  • launch4j: net.sf.launch4j.ExecException: Exec failed (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 Jun 09 '11 at 13:34
  • What operating system, and what user are you logged in as – Woot4Moo Jun 09 '11 at 13:45
  • I am using windows 7, logged as admin. – Manikandan Jun 09 '11 at 13:57
  • `WindRes.exe` and `LD.exe` are part of [WinGW](http://www.mingw.org/) binutils... The version that is used in Launch4J is 2.15.90. You need to get new version that works in Windows 7. Replace them in `%ProgramFiles%\Launch4j\bin` – ecle Feb 18 '12 at 07:47
  • Thanks for the suggestion eee, but it does not work. I've updated both files to the ones found in MinGW binutils 2.22 (the latest as of time of writing), to no effect. – LeigerGaming Sep 09 '12 at 03:57

4 Answers4

8

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

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
  • 1
    yes, change the icon from format png to ico ,solved it ,the exception log is: net.sf.launch4j.ExecException: Exec failed (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 at net.sf.launch4j.Util.exec(Util.java:156) at net.sf.launch4j.Cmd.exec(Builder.java:212) at net.sf.launch4j.Builder.build(Builder.java:96) – Alter Hu Jun 30 '16 at 00:57
3

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.

Gene
  • 46,253
  • 4
  • 58
  • 96
1

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?

Andrew Swan
  • 13,427
  • 22
  • 69
  • 98
0

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>
predi
  • 5,528
  • 32
  • 60