0
votes

Why does my code (compiles fine) gives me the following error?

Main method not found in class ImageTool, please define the main method as: public static void main(String[] args)

Code:

public class ImageTool {

public static void main(String[] args) {

    if (args.length <1) {
        System.out.println("Please type in an argument");
        System.exit(-1);
    }
    if (args[0].equals("--dump")) {
        String filename = args[1];
        int[][] image = readGrayscaleImage(filename);
        print2DArray(image);
    } else if (args[0].equals("--reflectV")) {
        String filename = args[1];
        int[][] image = readGrayscaleImage(filename);
        int[][] reflect = reflectV(image); //reflectV method must be written
        String outputFilename = args[2];
        writeGrayscaleImage(outputFilename,reflect);
    }
}
1
This is why I hate eclipse. - Pavel

1 Answers

0
votes

Your main method looks fine.

1) Probably your .class file does not correspond to your .java file.
I would try to clean up my project (if I was using an IDE and getting this).
That is: delete the .class file, regenerate it from the .java file.

2) Seems you're not running ImageFile but some other class,
even though you think you're running ImageFile. Check what
your IDE is running behind the scenes.

I hope one of these two suggestions would help.