Compile jar for exe and no longer need to have a JRE

Asked

Viewed 5,429 times

4

One more problem here, and I need your help. I downloaded a program that converts jar files to exe. The only problem is I still need the JRE. Is there any way to convert the program to exe and then not need the JRE (or the JRE go inside the exe)?

Explaining: I want to convert from jar to exe and then not need the JRE (or it will be embedded in the program)

  • I don’t think it’s possible, since you would have to install the JRE on the guy’s machine, maybe you can create some script by running the . exe "jar" it starts the script by checking if there is a JRE installed or not, if there is not you simply install the one that is "packaged", but would have a script for each platform, which would lead you to have a JRE for each platform. And then my friend It starts to get complicated.

3 answers

4


There are some (commercial) tools that convert a JAR to executable, such as the Excelsior or the Jexepack, that can do what you want. Another alternative is to create an installation program that, in addition to installing your program, also install the JRE if necessary. The install4j It’s one of those tools. Finally, as @Eduardobrj suggested, you can also distribute JRE (both its classes and java.exe) together with your application (according to this java thread.com (en)).

2

Once dependent on the JVM forever dependent on it. So as to the question of not needing the JRE the simplistic answer is... impossible, because the code is based on functionality and JAVA code that the application uses.

That being said... some solutions are possible that can compress the JAR(s) inside an EXE, but include the JRE inside I do not know.

However and in response... the best solution is with the GCJ compiler.

GCJ can compile Java source code for Java bytecode (class files) or directly for native machine code, and Java bytecode for native machine code.

In this sense this will then be the solution to the question posed, but, "everything has a but" this solution poses some problems in the medium term regarding compatibility and maintenance during the lifetime of application as we can no longer count on what JAVA has the best in my opinion. Operating system abstraction and in particular all implicit support in JAVA tools.

1

Executable without including JRE (generating native code)

There are currently alternatives such as Graalvm generating native code without the need to include the JRE.

Note that this strategy is different from those cited above, among which there are also options such as Launch4j.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.