Question

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!!

Was it helpful?

Solution

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

OTHER TIPS

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

gcj --main=Program Program.java

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top