09.24.06

Java programming with gcj

Posted in Java at 3:00 pm by Pirate Praveen

How to compile and run java programs using GCJ ?

$ gcj -C hello.java

is similar to javac hello.java and it creates a class file hello.class

$ gij hello

is similar to java as it executes bytecode in hello.class

what gcj offers that is not available with reguar jdk is support for creating binaries

$ gcj hello.java --main=hello

or if you already have the class file

$ gcj hello.class --main=hello

will create a binary file a.out and you can execute it using

$ ./a.out

it is similar to compiling with gcc and you can specify a different output file with -o option

$ gcj hello.java --main=hello -o hello
$ ./hello

More information on gcj see http://gcc.gnu.org/java/

Leave a Comment