Tuesday, January 25, 2005

Easy GNU gcj Java native compiler install on OS X

Tired of painful gcc/gcj builds on Mac OS X in order to get native Java compilation? Here is a Sourceforge project for high performance computing tools for OS X.

Gaurav Khanna (Physics Department, University of Massachusetts at Dartmouth) has pre-built gcj. Here is a link to a pre-built kit. Assuming that your web browser unGZIPed the file to gcj-bin.tar, just type:
sudo tar -xvf gcj-bin.tar -C /
to install in /usr/local. You can compile and run like this:
gcj --main=Test -o Test Test.java

./Test
For most purposes, stick with Sun's JDK and runtime kit - however, there are great reasons to also be able to generate native Java executables; for example: faster startup for small programs, test development targeted for Linux for GPLed projects that you do not want to use Sun's non Free Software kit for, etc.

No comments: