I'm using various OpenJDK distributions because I'm not sure if I have an Oracle-Java license. Because of my work, I sometimes make client-type apps, so I made it in Java because it can support Mac / Win (relatively easily). If the jar file is left as it is, some people may not be able to use it due to the problem of association, so it is very difficult to exe, so I wrapped it in exe with launch4j, It turns out that it doesn't start with certain OpenJDK. The following is the remedy. (In addition, since there is a part to edit the registry, we can not take responsibility for troubles as usual)
・ Amazon Coretto ・ AdoptOpenJDK
However, Amazon Coretto uses Liberica OpenJDK because JavaFX media support has not been implemented yet, and Adopt does not have JavaFX. This Liberica can't run launch4j. (I haven't tried it, but zuru OpenJDK seems to be useless)
-JAVA_HOME is set.
-Since it is also added to PATH, the java
command can be used from the command prompt etc.
-However, launch4j cannot be started because it is said that there is no JDK.
https://docs.oracle.com/javase/jp/9/install/installation-jdk-and-jre-microsoft-windows-platforms.htm#JSJIG-GUID-47C269A3-5220-412F-9E31-4B8C37A82BFB The normal JDK installer writes the Windows registry key. Since launch4j is a method of reading and judging the above registry key, it does not work because the registry key is not written depending on the OpenJDK distribution.
** Promise: Make a backup just in case before changing the registry. ** **
After trying various things, I was able to start it by adding this key.
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8
So, additional commands (from the command prompt in admin mode)
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" /v CurrentVersion /t REG_SZ /d "1.8.0_252"
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8" /v JavaHome /t REG_SZ /d "%JAVA_HOME%\jre"
Rewrite "1.8.0_252" on the first line to the Java version as appropriate. Also, match the "1.8" part of the path to the version in the same way.
(Maybe this is also)
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8.0_252"
If the jar doesn't launch with a double click,
HKEY_CLASSES_ROOT¥.jar
Sometimes it works if you remove the registry key and reinstall JRE.
https://sourceforge.net/p/launch4j/feature-requests/103/ https://github.com/AdoptOpenJDK/openjdk-installer/issues/64
Recommended Posts