简体   繁体   中英

Java cannot find or load main class?

I cannot resolve the current issue I am experiencing with Java. I am familiar with PHP/MySql, but not with Java.

Here is my

package day1.examples;

public class MyFirstClass
{
    public static void main(String[] args)
    {
        System.out.println('Hello World');
    }
}

When I go to run the program as Java, I receive the following warning: 当我以Java运行程序时,收到以下警告:

在此处输入图片说明

Then, I am receiving the following error in my console: Error: Could not find or load main class day1.examples.MyFirstClass 在此处输入图片说明

Why is the above code (which I assume is appropriate) not working? 上面的代码(我认为合适)为什么不起作用? Furthermore: Why am I receiving errors?

This is my first day using Java 这是我使用Java的第一天

在此处输入图片说明

从项目中删除当前绑定的JRE,并使用本地系统上存在的JRE添加新的系统库。

The reason it will not work is because the compilation is failing. The reason it is failing it because you used single quotes (') to enclose "Hello World". You should use double quotes (") as you are trying to indicate a String, single quotes are used for individual characters.

You should tell eclipse which Main calss you want to run. Go to Run --> Run Configurations.. and select the main class to run.

System.out.println('Hello World'); is not valid Java. Try System.out.println("Hello World");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM