Eclipse not recognizing my "Main" method
I'm trying to write a "Hello, World" variant program in Eclipse, and I can't seem to be able to run my program.
Here's the code:
/**
*
*/
package GreeterPackage;
/**
* @author Raven Dreamer
* Prints out "Hello, World" in three languages:
* English, French, and Spanish.
*/
public class GreeterProg {
/**
* returns "Hello, World" three times, once
* in English, once in French, and once in
* Spanish.
*/
public static void Main(String[] args){
/** instances of the three greeter
* classes so the non-static methods
* can be called.
*/
EnglishGreeter eng = new EnglishGreeter();
FrenchGreeter fre = new FrenchGreeter();
SpanishGreeter spa = new SpanishGreeter();
System.out.println(eng.greet());
System.out.println(fr开发者_如何转开发e.greet());
System.out.println(spa.greet());
}
}
And here's my code for SpanishGreeter (French and English greeter are identical, currently)
/**
*
*/
package GreeterPackage;
/**
* @author Raven Dreamer
* Returns "Hello, World!" but in Spanish!
*/
public class SpanishGreeter extends greeter {
/**Spanish string of "Hello, World!"
*/
private String GREET = "¡Hola, World!";
/**
* returns "Hello, World" in Spanish
*/
public String greet() {
return GREET;
}
}
The code compiles fine with no errors, but when I try to run the program as a java application, I get the following error:
So I am left baffled as to what, exactly, the problem is. Am I missing something salient in terms of how I set the project up in the first place?
The problem is that you have Main with a capital letter. Java is case-sensitive.
The full method signature is: public static void main(String [] args)
Your main method needs to be a lowercase "main".
"main" must be in lowercase only. Java method names are case-sensitive.
精彩评论