This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Unable to compile java file with gcj 4.1.1: undefined reference to main


I am having trouble building a java file with gcj. If I attempt to build
it from the obfuscated class file (a.class) I get the error message:

storri@base$ gcj a.class
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../crt1.o: In function `_start':
init.c:(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status

So I though okay I will let gcj reading the straight Java source file. I
get the same error message. Given the source file below is there any
reason why GCJ cannot compile it?

Stephen

----------------------
class Fibonacci {

	public int calculate ( int n )
	{
		int output = 0;

		if ( n > 1 )
		{
			output = calculate ( n - 1 ) + calculate ( n - 2 );
		}
		else
		{
			output = n;
		}

		return output;
	}

	public static void main ( String[] inc )
	{
		if ( inc.length > 0 )
		{
			Fibonacci f_ref = new Fibonacci();

			int n = Integer.parseInt(inc[0]);
			while ( n != -1 )
			{
				System.out.println( "Calculated fibonacci number: " +
f_ref.calculate ( n ) );
				n--;
			}
		}
		return;
	}
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]