0

Hey,firends,This is my first post.

I'm just begin to using Gcc to compile java,and I have some trouble in doing this.

My input and output:

import java.io.*;
import java.util.*;

public class Program{
    public static void main (String args[]) throws Exception    {
        BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in));
        String line = stdin.readLine();
        StringTokenizer st = new StringTokenizer(line);
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        System.out.println(a+b);
    }
}

cmd:gcj Porgram.java

<2>output:

E:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a:main.c:<.text+0xd2>:undefined reference to '_WinMain@16' collect2: ld returned 1 exit status

Any help would be very much appreciated!!

R Samuel Klatchko
  • 74,869
  • 16
  • 134
  • 187
huaigu
  • 557
  • 3
  • 5
  • 9
  • Ouch. Your formatting got destroyed there. Indent all of your code by four spaces (just select it all and press the 'code' formatting button) – goffrie Jul 19 '10 at 03:56

2 Answers2

2

Gcj neds to be told which of the classes it is compiling contains the main method. You can do this by using the --main command line parameter:

gcj --main=Program Program.java
Jörn Horstmann
  • 33,639
  • 11
  • 75
  • 118
0

You need to tell gcj the name of the class with the main method:

gcj --main=Program Program.java

Hendrik Brummermann
  • 8,242
  • 3
  • 31
  • 55