开发者

Eclipse not recognizing my "Main" method

开发者 https://www.devze.com 2023-02-06 05:31 出处:网络
I\'m trying to write a \"Hello, World\" variant program in Eclipse, and I can\'t seem to be able to run my program.

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:

Eclipse not recognizing my "Main" method

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消