There are several ways to make your executable java applications by this manner. You can use commercial products, such as "Zero G InstallAnywhere", "Advanced Installer" and "Excelsior JET". The last one claims that have a powerful optimizer which makes java applications run faster than running on a normal JRE. Here is a benchmark by Excelsior. "Zero G InstallAnywhere" is widely used by companies who release their software, or developer's packages in Java language.
This is the most easy (but not free) solution. There is also a free solution, which is to use GCJ (GNU Compiler for Java). NativeJ, is a free fron-end for GCJ (since GCJ is hard to deal with in Windows). NativeJ's website says:
NativeJ is a Java to native compiler. It allows AOT (ahead of time) compilation of your Java applications.With NativeJ, you can create real standalone native binaries (.exe on Windows) which will no longer depend on a JRE.
GCJ is an incomplete Java compiler and runtime environment. It is absolutely open source, and runs on platforms supported by GCC (Linux/UNIX, Window, Solaris). By the time of this article, the latest (non-stable) version of GCJ was 4.1. I'm, not sure but I think that 4 should be compatible with Sun JDK 1.4. This is a nice idea to use GCJ as a free tool to make your Java applications into Windows (or other supported platforms) native executable, but there are some problems with that. Since it is incomplete, you can not be sure that all your java files can be compiled and linked with GCJ. The other problem is that there is not an IDE which supports GCJ as a JRE and Java compiler and linker. Eclipse, NetBeans, IntelliJ IDEA, JBuilder, JDeveloper, WSAD, JCreator, etc.; none of them does support GCJ. The best one for this mean may be Eclipse, since there are hundreds of plugins written for it. There is only one plugin for Eclpise which auto generates a GNU Makefile for a java project. This Makefile can only be run under Linux platforms! Here is a nice article about "Compiling Java with GCJ" by Per Bothner.
The second approach is to make .exe files which still relies on JRE. It means that one should have JRE installed on his/her computer in order to be able to run the binary executable file. In fact it works as a simple batch (.bat) file script: checking if JRE is available on user's system and run the main class with class path properly set. This way is nice for those who want to give their application to IT professionals, developers, or someone who may use the application on a machine with proper JRE. The size of .exe file will not be an issue, since it doesn't put library files in the exe file. There are a lot of solutions for this mean:
- A nice, quick and easy exe maker is the NSIS exe compiler. There are a number of scripts on its Wiki pages: Java Launcher and A slightly better Java Launcher!. A very nice IDE to work with NSIS scripts is EclipseNSIS. It has a number of wizards for making different kind of installers. The Zekr Project also uses NSIS both as .exe java launcher and installer.
- JSmooth: it is a small, nice, free, open source java native compiler. It makes a single exe file (with a given icon), which locates JRE, sets classpath and runs the main class. I really don’t like it because of the size of the exe file, which is at least 400KB! JSmooth is located at: http://jsmooth.sourceforge.net.
- DobySoft NativeJ: Here is a page for free applications used NativeJ for making exe.
- Install4J: a small Java installer
- JEXECreator
- JexePack: without GUI, expensive one!
No comments:
Post a Comment