简体   繁体   中英

Eclipse does not run the the static main class

I used the chrome plugin ( codin game Sync ) of https://www.codingame.com , to download a class in to my eclipse Version: Luna Service Release 2 (4.4.2) . Windows 8.1 Enteprise , and it is a very simple class:

class Player {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int W = in.nextInt(); // width of the building.
        int H = in.nextInt(); // height of the building.
        int N = in.nextInt(); // maximum number of turns before game over.
        int X0 = in.nextInt();
        int Y0 = in.nextInt();
        System.out.println("0 0");
        // game loop
        while (true) {
            String bombDir = in.next(); // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)

            // Write an action using System.out.println()
            // To debug: System.err.println("Debug messages...");


            // the location of the next window Batman should jump to.
            System.out.println("0 0");
        }
    }
}

But it never prints anything into my console.

Point:

I used to add the class into the build path but it still does not print anything, but it runs the project.

Right click on project -> Properties -> Java build path -> Tab Source -> choose project name/src/main->java

There is only one, tab open on the domain codin.com

I suspect your app is working but you are not aware of it :) Do this:

    Scanner in = new Scanner(System.in);
    System.out.println("Hello App");
    int W = in.nextInt(); // width of the building.
    int H = in.nextInt(); // height of the building.
    int N = in.nextInt(); // maximum number of turns before game over.
    int X0 = in.nextInt();
    int Y0 = in.nextInt();
    System.out.println("0 0");

if you see the message "Hello App" in the console then the app is just running waiting for you to imput some ints..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM