How to create an .exe program with Java?
Hi everyone, what is the easiest way to create an .exe program with Java?
Is there a variant that works without having Java on the PC?
Ps: I have a finished program of course, it's just a matter of getting it usable for a user
The most reliable is GraalVM Native Image, where a compiler toolchain must be installed.
https://www.graalvm.org/22.0/reference-manual/native-image/
Otherwise, there is the possibility to bundle a JDK with the application, even with the installer.
https://www.baeldung.com/jlink
https://www.baeldung.com/java14-jpackage
I have to ask again: what variants is the one where the user needs nothing else?
On the left, it also looks like code is written, there is a preamble for the whole ? Like other topics: "create your gui" or "read files in java"?
With other words: I want for the first time, as I have recently been programming, a program to the extent that I could theoretically give it to someone who can do it without extra installations
Then Java is the wrong choice with its architecture. The strength of Java is that it runs on all possible platforms. To do this, Commission but a corresponding runtime environment is installed on the respective platform.
Theoretically, your Java program would also be running on my Linux system. But with a .exe, my computer can't start. That's why I need the Linux runtime environment and could run your .jar in it.
It looks similar on Windows. There it is then the JRE: Java Runtime Environment or in German: Java runtime environment.
Thank you for your answer. I have to say it's a little frustrating….if you started python then learned java because it's "maybe more relevant in job/studies" and then no finished program gets there. If I can just ask a little cheeky. What would you advise a beginner who wants to see what is "ready" specifically a program from the learned?
The things I described in my answer. This allows you to build a nicely packaged program that you don't see as a "non-coder" that it is written in Java.
Nevertheless, one must say, of course, that this is not the most common application for Java. It is mainly used for large services that are not used directly by end users on their own devices (besides Android apps that are also commonly written in Java). These are the applications that run on the thick server landscapes in the background. As a layman, you get little of it, but that's where "the software" plays out today.
Thanks for understanding.
But then asked differently – it often means learning Java:
What is the next step to have a running program for a non-coder user?
Would you tell beginners:
"ok you now have your finished program – but do you want to make it available to end users you need to learn c or other languages?"
Ps: I know how you say my program is already running. But I hope my demand is clear
JAVA is not intended for this. Java programs SHOULD run in the JVM to be platform independent.
If the programs were not encapsulated in a JVM, it would be impossible to achieve the platform impractice. If you want your code to be compiled as an independent running program in an exe for Windows, then use a language that uses a compiler for Windows. (C++/C#/VB/Delphi as examples.)
Ok thanks I had read this with the platform independence a few times but hoped that it would have to go…
How about apps and games like minecraft?
Will Minecraft ALWAYS install Java?
Because you say it always needs a JVM
Enabled program does not necessarily have to be in exe format.
Java also has a jar format. If the target computer has no Java installed, it should function as a portable app in which the Java runtime file is integrated.
Yes, it is possible to connect a Java program with a Java runtime file in a portable app, so it also works on a PC without installed Java.
Gemini confirms my acceptance:
Two approaches:
1. Pack Java program in a JAR file:
Two. Java program as portable app with JRE:
Advantages:
Cons:
Further information:
Ask the user to install Java.
Thank you.
Then you'd have to pack a Java Runtime into your program, then that should go. Unfortunately, I don't know what it looks like with the Java license.
Completely unproblematic. There are only individual commercial JDKs (approximately Azul) that do not allow this easily.
Since approx. Java 9 is also the method recommended by Oracle for desktop apps to deliver a JVM instead of relying on a system-wide installed.
Apart from that, you can also build native binaries with GraalVM.
Thanks for the info, again what learned 🙂 I can do something Java but have never really dealt with desktop programs.
Not really the strength of Java, but it is.