简体   繁体   English

Launch4j:此应用程序需要使用 maven 的 Java Runtime Environment 1.8.0_161?

[英]Launch4j:This application requires a Java Runtime Environment 1.8.0_161 using maven?

I am using the launch4j maven plugin to generate an .exe for my application.I would like also to embed a bundled JRE.i managed to achieve it with success from my pc which i have java 1.8.0_161 installed.我正在使用launch4j maven插件为我的应用程序生成一个.exe。我还想嵌入一个捆绑的JRE。我设法从我安装了java 1.8.0_161的PC上成功实现了它。 My problem now is that when i try to execute the .exe from a VM machine that has not java installed i took this error我现在的问题是,当我尝试从未安装 java 的 VM 机器执行 .exe 时,出现此错误

CryptoAlertNews: This application requires a Java Runtime Environment 1.8.0_161

Why does this happen what I am doing wrong?为什么会发生这种情况我做错了什么? This is what I have in the pom.xml:这是我在 pom.xml 中的内容:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.panos</groupId>
  <artifactId>com.panos</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>com.panos</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.21</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.6</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.1.0</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-source</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>com.panos.App</mainClass>
            </manifest>
          </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.akathist.maven.plugins.launch4j</groupId>
        <artifactId>launch4j-maven-plugin</artifactId>
        <version>1.7.25</version>
        <executions>
          <execution>
            <id>l4j-clui</id>
            <phase>package</phase>
            <goals>
              <goal>launch4j</goal>
            </goals>
            <configuration>
              <headerType>console</headerType>
              <outfile>target/CryptoAlertNews.exe</outfile>
              <icon>src/resources/Image/photo.ico</icon>
              <jar>target/com.panos-1.0-SNAPSHOT-jar-with-dependencies.jar</jar>
              <errTitle>CryptoAlertNews</errTitle>
              <classPath>
                <mainClass>com.panos.App</mainClass>
                <addDependencies>false</addDependencies>
                <preCp>anything</preCp>
              </classPath>
              <jre>
                <path>src/resources/jre</path>
                <bundledJre64Bit>false</bundledJre64Bit>
                <bundledJreAsFallback>true</bundledJreAsFallback>
                <minVersion>1.8.0_161</minVersion>
                <jdkPreference>preferJre</jdkPreference>
                <runtimeBits>64/32</runtimeBits>
              </jre>
              <versionInfo>
                <fileVersion>1.0.0.0</fileVersion>
                <copyright>C</copyright>
                <txtFileVersion>${project.version}</txtFileVersion>
                <fileDescription>${project.name}</fileDescription>
                <productVersion>1.0.0.0</productVersion>
                <txtProductVersion>1.0.0.0</txtProductVersion>
                <productName>${project.name}</productName>
                <internalName>AppName</internalName>
                <originalFilename>CameraControl.exe</originalFilename>
              </versionInfo>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <resources>
      <resource>
        <directory>src/resources</directory>
        <includes>
          <include>**/*.exe</include>
          <include>**/*.txt</include>
          <include>**/*.properties</include>
          <include>**/*.crx</include>
          <include>**/*.fxml</include>
          <include>**/*.css</include>
          <include>**/*.json</include>
          <include>**/*.zip</include>
          <include>**/*.dll</include>
          <include>**/*.ico</include>
        </includes>
      </resource>
    </resources>
  </build>
</project>

You must be aware that Launch4J does NOT embed the JRE, but instead reference it on runtime.你必须知道,Launch4J没有嵌入的JRE,而是引用它的运行时间。

The <path> contents should be a route that points to a JRE when the EXE is executed. <path>内容应该是执行EXE时指向 JRE 的路径。

You can distribute your app with a ZIP, and then put a folder jre at the root folder, and your .EXE in the same folder.您可以使用 ZIP 分发您的应用程序,然后将文件夹jre放在根文件夹中,并将您的.EXE放在同一文件夹中。

Then your ZIP contents would be as following:那么您的 ZIP 内容将如下所示:

|jre (with the contents of the jre uncompressed, including bin directory)
|app.exe

You can find a question similar to yours here: How to bundle a JRE with Launch4j?您可以在此处找到与您类似的问题: 如何将 JRE 与 Launch4j 捆绑在一起?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 launch4j 捆绑 JRE 错误。“此应用程序被配置为使用捆绑的 Java 运行时环境,但运行时丢失或损坏” - launch4j bundled JRE error .“This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted” 用launch4j和maven包装Java命令行应用程序 - Wrapping a java command line application with launch4j and maven java maven launch4j没有启动画面; 同一罐子,并使用Launch4J GUI启动画面或JAVA-JAR:好 - java maven launch4j no splash screen; same jar and using Launch4J GUI splash screen OR JAVA - JAR: Ok 无法运行使用launch4j转换的Java应用程序(exe) - Unable to run java application (exe) converted using launch4j 使用 Launch4j 将 Java 应用程序固定到 Windows 7 任务栏 - Pinning a Java application using Launch4j to the Windows 7 taskbar JDK 1.8.0_161 中的 Java Mission Control 在 Mac OS X 上启动时冻结 - Java Mission Control from JDK 1.8.0_161 frozen upon startup on Mac OS X 如何将 JRE 捆绑到 Java 应用程序的 EXE 中? Launch4j 说“运行时丢失或损坏。” - How do I bundle a JRE into an EXE for a Java Application? Launch4j says “runtime is missing or corrupted.” 如何将launch4j与Java自定义运行时映像一起使用? - How to use launch4j with a Java custom runtime image? 尝试使用Alakai插件将Launch4j集成到Maven项目中 - Trying to integrate Launch4j in a Maven project using Alakai plugin 使用launch4j和maven时未创建.exe - .exe is not created when using launch4j and maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM