[K12OSN] Re: Gcj vs javac

Lee Harr missive at hotmail.com
Thu May 5 23:13:54 UTC 2005


>I'm preparing for an eventual programming class in Java.  I had a few
>semesters of Java in college.  I tried the very simple  "Hello World" using
>gcj, only to have it tell me it didn't know what main was ("undefined
>reference to main").


Apparently with gcj you need to tell the compiler which class
has the main function.


So if this is your hello.java file:

class hello_java
{
        public static void main(String args[])
        {
           System.out.println("Hello World!");
        }
}



You could compile it with:

gcj --main=hello_java hello.java


And run it with:

./a.out

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




More information about the K12OSN mailing list