Main Method Not Found Even If I'Ve Declared It

Main method not found even if I've declared it

As said in my comments, looks like you've declared a String class among your own classes. To prove this, I've created a basic example:

class String {
}

public class CarelessMain {
public static void main(String[] args) {
System.out.println("won't get printed");
}
public static void main(java.lang.String[] args) {
System.out.println("worked");
}
}

If you execute this code, it will print "worked" in the console. If you comment the second main method, the application will throw an error with this message (similar for your environment):

Error: Main method not found in class edu.home.poc.component.CarelessMain, please define the main method as:

public static void main(String[] args)

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

You can only run java file with main method.

In your case, you can only run DemoBook.java



Related Topics



Leave a reply



Submit