Launch4j:This 应用程序需要 Java 运行时环境 1.8。0_161 使用 maven?
Launch4j:This application requires a Java Runtime Environment 1.8.0_161 using maven?
我正在使用 launch4j maven 插件为我的 application.I 生成一个 .exe 还想嵌入一个捆绑的 JRE.i 设法从我的电脑上成功实现它 java 1.8.0_161 安装。我现在的问题是,当我尝试从未安装 java 的 VM 机器上执行 .exe 时,出现此错误
CryptoAlertNews: This application requires a Java Runtime Environment 1.8.0_161
为什么我做错了会发生这种情况?这就是我在 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>
您必须知道 Launch4J 不 嵌入 JRE,而是在运行时引用它。
<path>
内容应该是在执行 EXE 时指向 JRE 的路由。
您可以使用 ZIP 分发您的应用程序,然后将文件夹 jre
放在根文件夹中,并将您的 .EXE
放在同一文件夹中。
那么你的 ZIP 内容如下:
|jre (with the contents of the jre uncompressed, including bin directory)
|app.exe
您可以在这里找到与您的问题类似的问题:How to bundle a JRE with Launch4j?
我正在使用 launch4j maven 插件为我的 application.I 生成一个 .exe 还想嵌入一个捆绑的 JRE.i 设法从我的电脑上成功实现它 java 1.8.0_161 安装。我现在的问题是,当我尝试从未安装 java 的 VM 机器上执行 .exe 时,出现此错误
CryptoAlertNews: This application requires a Java Runtime Environment 1.8.0_161
为什么我做错了会发生这种情况?这就是我在 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>
您必须知道 Launch4J 不 嵌入 JRE,而是在运行时引用它。
<path>
内容应该是在执行 EXE 时指向 JRE 的路由。
您可以使用 ZIP 分发您的应用程序,然后将文件夹 jre
放在根文件夹中,并将您的 .EXE
放在同一文件夹中。
那么你的 ZIP 内容如下:
|jre (with the contents of the jre uncompressed, including bin directory)
|app.exe
您可以在这里找到与您的问题类似的问题:How to bundle a JRE with Launch4j?