Articles‎ > ‎

Java 2 Exe

Compiling Java to Native Exe (Ahead of Time Compiler)

Before writing anything, I shall mention that this information is taken from the Web. Special thanks to excelsior-usa.com. The motivation is: It took lot of time for me to understand the concepts. I am putting it in Question & Answers format to make the life of frustrated people much easier.

 

What is Java to Executable?

Java to executable here means an executable file which is created from Java source code. That executable file does not need any JVM/JRE to run.

Below is the list of ways you convert Java to Exe (which uses JVM)

a)       Batch File

Create a batch file which runs your java program. E.g.

Java com.dt.example.FirstProgram

 

b)       Executable Jars

You can compile your classes into jar file. In the manifest.mf file mention about the main class.   Main-Class: MainProgram

 

c)        Installation Packaging tools

There are few tool available, both open source and commercial that package java Programs. e.g. jsmooth, launch4j, advancedinstaller

 

Why would I need native executable?

Good Question. In most of the scenarios you would not want that. For most people, they want their Java could to be created as executable though it finally uses JVM only (mentioned above). You may want the native (AOT) compiler for the following reasons:

a)       Security: You would want Java to Exe mainly for the security reasons. Any Java program which uses JVM can be decoded easily. This explains very well why the security is a concern.

b)       Performance: Well, this is subjective / debatable. It was thought that native executable are faster and perform better, but the achievements of Virtual machines like hot-spot, etc gives competition to native executable.

 

Whatever, I need a native compiler. Which one shall I use?

There are not much options for Native Complications. Options are :

1.       GCJ

2.       Excelsior – Jet

 

Comments