Create a native Java executable, revisited
You can create a native executable — but do you really want to?
URLs for various native compilers and C translators can be found in the Resources section below.
Be warned, though: you may lose certain features of the Java platform if you compile to native code. Further, some of the older compilers will not allow the dynamic addition of new classes at runtime. When choosing a compiler, carefully compare the compiler’s feature list against your software’s requirements, as expected JVM behaviors and features may not carry over to the compiled code. Native compilers can also be expensive. If you are concerned about performance, adaptive compiling technologies such as HotSpot and JIT have improved Java performance greatly. Happily, they keep getting better. If your intention is to simplify the user experience by not requiring the user to type java <class name>
at the command line, you can simply create a .bat
file for Windows or a shell script for Unix that takes care of setting CLASSPATHs and running the program. A batch file could be as simple as:
run_that_program.bat
java program_class_name