Search code examples
javamavenlaunch4j

Launch4j redirect to download java version


I used Launch4j plugin in my Java project with Maven. When I compile project to exe and run on Windows system where there is no Java installed, it redirects (automatically open web browser) to download Java but with 32-bit version. I want to redirect to download 64-bit newest version. Is it possible?

My plugin definition in Maven looks like

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

I tried to add in <jar>...</jar> the <runtimeBits>64</runtimeBits> and when run exe file pop up shows "The application requries a Java Runtime Environment 1.8.0_101 (64-bit)" and after click OK, it redirect to download 32-bit version, with page address https://java.com/pl/download/

EDIT

I tried also add in <jar>...</jar> the <bundledJre64Bit>true</bundledJre64Bit> but can not end compilation and return error as below

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

Solution

  • SOLUTION

    Before <jre>...</jre> just add <downloadUrl>https://java.com/en/download/manual.jsp</downloadUrl> and that's it.

    Redirect us to page when user can choose the java version according to system and which version must download by adding a <runtimeBits>64</runtimeBits> in <jre>... brackets.