I want to create a simple java class, with a main method, but when I compile my code, I get this error message :
Error: Main method not found in class errors.TestErrors, please define the main method as: public static void main(String[] args)
This is the source code :
package errors;
public class TestErrors {
public static void main(String[] args){
System.out.println("hello");
}
}
Why I'm seeing this error, as you can notice I've alreader declared the main method !
javac
?String
class among your classes.Class
and it was because I carelessly created aclass Class
for testing purposes. Similar can happen withString
and other. To prove this, try using the full name ofString
class, this means, change yourmain
method to receive ajava.lang.String[] args
argument .