简体   繁体   中英

Need help in Launch4j

I have an ant file which creates an installer. I used launch4j and innosetup. Installer get created. But I got the following error

该应用程序被配置为使用捆绑的Java运行时环境,但是运行时丢失或损坏。

My ant file is:

<?xml version="1.0"?>
<project basedir="." default="build" name="JavaSamp">
    <!--Creation of JavaSampSetup.exe-->
    <target name="build">
        <!-- Creation of classes folder -->
        <mkdir dir="classes" />
        <!-- Compilation of classes -->
        <javac srcdir="src" destdir="classes" />
        <!-- Creation of install/lib -->
        <mkdir dir="install/lib" />
        <!-- Creation of JavaSamp.jar -->
        <jar destfile="install/lib/JavaSamp.jar" basedir="classes" />       
        <!-- Copying process of 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>

        <!-- Creation of JavaSamp.exe using Launch4j -->
        <exec executable="C:\Program Files\Launch4j\launch4jc.exe">
            <arg value="${basedir}\installerLaunch4j.xml" />
        </exec>

        <!--Creation of JavaSamp.exe using Inno Setup-->
        <exec executable="C:\Program Files\Inno Setup 5\ISCC.exe">
            <arg value="${basedir}\installerInnoSetup.iss" />
        </exec>

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

And the Launch4j configuration file:

<launch4jConfig>
  <dontWrapJar>true</dontWrapJar>
  <headerType>gui</headerType>
  <jar></jar>
  <outfile>install\JavaSamp.exe</outfile>
  <errTitle></errTitle>
  <cmdLine></cmdLine>
  <chdir>.</chdir>
  <priority>normal</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
  <supportUrl></supportUrl>
  <customProcName>true</customProcName>
  <stayAlive>false</stayAlive>
  <icon></icon>
  <classPath>
    <mainClass>JavaSamp</mainClass>
    <cp>lib/JavaSamp.jar</cp>
  </classPath>
  <jre>
    <path>jre6</path>
    <minVersion></minVersion>
    <maxVersion></maxVersion>
    <dontUsePrivateJres>false</dontUsePrivateJres>
    <initialHeapSize>0</initialHeapSize>
    <maxHeapSize>0</maxHeapSize>
  </jre>
  <versionInfo>
    <fileVersion>1.0.0.0</fileVersion>
    <txtFileVersion>1.0</txtFileVersion>
    <fileDescription>JavaSamp</fileDescription>
    <copyright>Copyright (c) 2011 Fsp</copyright>
    <productVersion>1.0.0.0</productVersion>
    <txtProductVersion>1.0</txtProductVersion>
    <productName>JavaSamp</productName>
    <companyName>Fsp</companyName>
    <internalName>JavaSamp</internalName>
    <originalFilename>JavaSamp.exe</originalFilename>
  </versionInfo>
</launch4jConfig>

There are certain conditions to be met when using JRE bundled or JRE download feature in Launch4J Launch4j JRE Installation or bundled

In your launch4j script, it only mentions <path> entry named as "jre", so you are applying the first condition which it results in such error:

<path> Run if bundled JRE and javaw.exe are present, otherwise stop with error.

Try to add <minVersion> entry with 1.6.0 and see what happens as it seems that your setup does copy JRE bundle into the "install" folder (I shall see your InnoSetup script file to confirm)

  <jre>
    <path>jre</path>
    <minVersion>1.6.0</minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>jreOnly</jdkPreference>
  </jre>

I hope in your InnoSetup script file has something like this:

[Files]
Source: "install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM