this afternoon I've finally completed my project in Java. So I decided to make it available for windows using launch4j to build the exe file.
Seemed something simple, but actually for me is not. My situation right now is the following:
- I've installed only the Java SE Development Kit (JDK) 19
- My jar file doesn't run with the double click (I've read it could be because with double click you're opening it with javaw instead of java) but works fine with the CMD using
java -jar "jar file path"
- If I double click on my exe it shows the CMD windows only for a split second and then disappears without writing anything. If I try to run it through the CMD it tells me that this exe need JRE to run (how's that possible if I have a JDK installed?)
- I can't find my JRE inside the JDK: I'm quite sure that JDK should contain JRE, but I can't find it in my installation folder of JDK 19
After describing you in the most detailed way my state, I want now to explicitly declare what I am aiming to:
- I would like to bundle my exe with a copy of the needed JRE, in order to make it run on other PC without an explicit installation of JRE
- I know this is possible since with Launch4J you can specify the path of the JRE to run your program. It is sufficient to put the JRE and the exe in a folder together and specify the relative path in the config file of launch4J (something like "./jrefolder" since they're in the same folder)
- What will happen with the newly correct exe in the other machines? Will it open using the javaw like the jar file in my PC?
Hope someone can give me support, cause this thing is driving my crazy since I've finished my project but still i can't deploy it officially