我有一个可创建安装程序的ant文件。我使用了launch4j和innosetup。安装程序被创建。但我收到以下错误





我的蚂蚁文件是:

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


以及Launch4j配置文件:

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

最佳答案

在Launch4J Launch4j JRE Installation or bundled中使用JRE捆绑或JRE下载功能时,需要满足某些条件。

在launch4j脚本中,它仅提及名为“ jre”的<path>条目,因此您正在应用第一个条件,它会导致这种错误:


  <path>
      如果存在捆绑的JRE和javaw.exe,则运行;否则,以错误停止。


尝试在<minVersion>中添加1.6.0条目,看看安装程序确实将JRE捆绑包复制到“安装”文件夹中后会发生什么(我将看到您的InnoSetup脚本文件进行确认)

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


我希望您的InnoSetup脚本文件中具有以下内容:

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

关于java - 在Launch4j中需要帮助,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6375964/

10-12 22:11