Why Exception in thread "main" java.lang.NoSuchMethodError: main?

Well as I researched it seems to be a common error, but through the information I collected, it is mainly caused by the misbehaviour of main method, while in here I inspected nothing.

import java.util.Scanner;

public class NBody {

    public static void main(double T, double dt, String filename) {

        In f = new In(filename);
        int N = f.readInt();
        double R = f.readDouble();

        Planet planets[] = new Planet[N]; 

        for (int i = 0; i < N; i++) {
            planets[i] = getPlanet(f);
        }

        StdDraw.setScale(-R, R);

        for (Planet star:planets) {
            star.draw();
        }
    /*
        for (Planet star:planets) {
            star.update(dt);
            StdDraw.picture(star.x, star.y, star.imgName);
        }
    */

    }

    public static Planet getPlanet(In file) {
        double x = file.readDouble();
        double y = file.readDouble();
        double xVelocity = file.readDouble();
        double yVelocity = file.readDouble();
        double mass = file.readDouble();
        String imgName = file.readString();
        Planet p = new Planet(x, y, xVelocity, yVelocity, mass, imgName);
        return p;
    }

}

So how can I solve this problem? I didn't transfer any arguments to it and the java NBody just fails (I compiled successfully, I could assure that).

Jon Skeet
people
quotationmark

Your main method has the wrong signature. To be an entry point for a Java application, it must have a single parameter of type String[] (and a void return type, and it must be public and static):

public static void main(String[] args)

or

public static void main(String... args)

The parameter name is unimportant.

You'll need to parse the command line arguments into appropriate types, e.g.

// TODO: Validation, e.g. that there are 3 command line arguments
// TODO: Use meaningful and conventional variable names
double T = Double.parseDouble(args[0]);
double dt = Double.parseDouble(args[1]);
String filename = args[2];

people

See more on this question at Stackoverflow