Launch4J 无法识别 Eclipse Temurin OpenJDK Java 17

Launch4J not recognizing Eclipse Temurin OpenJDK Java 17

我正在使用 Windows 10,我安装了 Java 17,JAVA_HOME 设置正确。 java --version 给出这个:

openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

在 Maven 父 POM 中,我通过 launch4j-maven-plugin 2.1.1 配置了 Launch4j,以使用我当前的 JRE 生成 EXE:

<plugin>
  <groupId>com.akathist.maven.plugins.launch4j</groupId>
  <artifactId>launch4j-maven-plugin</artifactId>
  <version>2.1.1</version>
  <executions>
    <execution>
      <id>generate-exe</id>
      <phase>package</phase>
      <goals>
        <goal>launch4j</goal>
      </goals>
      <configuration>
      ...
      <jre>
        <minVersion>${maven.compiler.release}</minVersion>
      </jre>
...

这个父 POM 还指定了 Java 8(虽然它需要 Java 9+ 来构建):

<properties>
  <maven.compiler.release>8</maven.compiler.release>
...

我的 CLI 项目 POM 使用上面的父 POM。我毫无问题地构建了 Maven 项目,它生成了 my-cli.exe。我可以运行my-cli.exe就好了

但我想在 My CLI 中使用 Java 17,这应该没问题,因为我已经安装了 Java 17。所以我在 My ClI 项目中设置了以下内容:

<properties>
  <maven.compiler.release>17</maven.compiler.release>
...

我清理并重建了项目,它像以前一样输出 my-cli.exe。但是当我尝试 运行 my-cli.exe 时,它会打印:

My CLI: This application requires a Java Runtime Environment 17

然后它打开我的浏览器 https://java.com/en/download/

来自 Launch4J Bug 197, it appears that Launch4J doesn't look at the JAVA_HOME environment variable, but instead looks at the Windows registry. That means it ignores any manually-installed JDKs. So I went to Adoptium 并使用安装程序安装了最新版本 OpenJDK17U-jdk_x64_windows_hotspot_17.0.2_8.msi。在我的 Windows 安装程序中,它显示“Eclipse Temurin JDK with Hotspot 17.0.2+8 (x64)。不幸的是,同样的事情发生了;Launch4J 仍然无法识别它。

为什么 Launch4J 无法识别 OpenJDK 17.0.2+8 是“Java Runtime Environment 17”?

显然根据 Launch4J Bug Feature Request 103, Launch4J doesn't look at the same registry keys that OpenJDK uses, and only works with Oracle JDK registry keys. There's an Adoptium Issue 64 要求 Adoptium 使用与 Oracle 相同的注册表项,但看起来由于陷阱而被放弃。

如上面的功能请求中所述,无论如何,Launch4J 都应该查看 JAVA_HOME 环境。

Launch4J 似乎无法与 OpenJDK 一起使用,这使得它在当今世界基本上毫无价值。真令人失望。