Launch4j 重定向下载 java 版本

Launch4j redirect to download java version

我在 Java 项目中使用 Maven 的 Launch4j 插件。当我在未安装 Java 的 Windows 系统上将项目编译为 exe 和 运行 时,它会重定向(自动打开网络浏览器)以下载 Java 但使用 32 位版本。我想重定向以下载 64 位最新版本。可能吗?

我在 Maven 中的插件定义看起来像

<plugin>
    <groupId>com.akathist.maven.plugins.launch4j</groupId>
    <artifactId>launch4j-maven-plugin</artifactId>
    <version>1.7.11</version>
    <executions>
        <execution>
            <id>l4j-gui</id>
            <phase>package</phase>
            <goals>
                <goal>launch4j</goal>
            </goals>
            <configuration>
                <headerType>gui</headerType>
                <outfile>target/Project.exe</outfile>
                <jar>target/Project.jar</jar>
                <priority>high</priority>
                <errTitle>project</errTitle>
                <classPath>
                    <mainClass>com.project.Main</mainClass>
                    <preCp>libs/*.jar</preCp>
                </classPath>
                <jre>
                    <minVersion>1.8.0_101</minVersion>
                </jre>
                <icon>${basedir}/build-resources/win/application-${ENV}.ico</icon>
            </configuration>
        </execution>
    </executions>
</plugin>

我尝试在 <jar>...</jar> 中添加 <runtimeBits>64</runtimeBits>,当 运行 exe 文件弹出时显示 "The application requries a Java Runtime Environment 1.8.0_101 (64-bit)",点击确定后,它重定向到下载 32 位版本,页面地址 https://java.com/pl/download/

编辑

我也试过在<jar>...</jar>中添加<bundledJre64Bit>true</bundledJre64Bit>但是无法结束编译和return错误如下

[INFO] --- launch4j-maven-plugin:1.7.11:launch4j (l4j-gui) @ stockbox-main ---
[INFO] Platform-specific work directory already exists: /Users/Arek/.m2/repository/net/sf/launch4j/launch4j/3.9
[ERROR] 
net.sf.launch4j.BuilderException: !Jre.bundled.64bit.invalid!
    at net.sf.launch4j.Builder.build(Builder.java:76)
    at com.akathist.maven.plugins.launch4j.Launch4jMojo.execute(Launch4jMojo.java:358)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

此处提供了详细信息 - 看看是否有帮助

http://launch4j.sourceforge.net/docs.html

<bundledJre64Bit>true|false</bundledJre64Bit>
<bundledJreAsFallback>true|false</bundledJreAsFallback>
<runtimeBits>64|64/32|32/64|32</runtimeBits>

解决方案

<jre>...</jre> 之前只需添加 <downloadUrl>https://java.com/en/download/manual.jsp</downloadUrl> 即可。

当用户可以根据系统选择 java 版本时,将我们重定向到页面,并且必须通过在 <jre>... 括号中添加 <runtimeBits>64</runtimeBits> 来下载哪个版本。