Skip to content
Advertisement

.exe file only runs using Java Dev Kit, instead of Java Runtime Environment

So I’ve recently made a small app for a high school class, and I want it to be able to run on any Windows computer with JRE installed and updated.

I’ve made the app in Eclipse, exported it as a runnable JAR file (making sure to have “Package required libraries into generated JAR” selected under Library handling), and then converted that to an executable file using Launch4J. When I first made the exe, under the JRE specification, I had the min JRE version set to 1.8.0 and I originally had the option selected that said “Prefer public JRE, but use JDK runtime if newer,” not thinking anything of it. The exe worked perfectly fine on my computer, so I sent it out to a few friends to have them test it out, and it didn’t work.

Turns out what had happened was the exe was running using my version of JDK, instead of using JRE. I tried making the executable again, this time selecting the option of “Only use public JREs.” When I built the executable this time, it wouldn’t run on my computer either, even though I have the latest JRE version installed, so I obviously think that somehow the runnable JAR file is being built without being able to be ran using JRE instead of JDK.

I’ve looked in the export options for eclipse, but from what I can tell there’s nothing I can change when exporting the runnable jar file to change how it runs.

Any help would be greatly appreciated.

Advertisement

Answer

Okay, so after some digging into the settings on a project I figured out how to get it to work.

You need to right click on the project you’re working on in Eclipse. Properties > Java Compiler

Under JDK Compliance, you need to uncheck “Use compliance from execution environment ‘JavaSE-14’ on the ‘Java Build Path’

Then under “Compiler compliance level:” you need to click on the drop down and choose 1.8.

After that you can export it as a runnable JAR and then convert it to .exe and everything should work perfectly!

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement