简体   繁体   English

eclipse时出错:线程“ main”中的异常java.lang.Error

[英]eror when get eclipse : Exception in thread “main” java.lang.Error

I created a new java project in Eclipse, then created a new class in it and write this codes in it: 我在Eclipse中创建了一个新的Java项目,然后在其中创建了一个新类,并在其中编写以下代码:

public class main {
    public static void main(String[] args) {
        system.out.println("hello world");
    }
}

This problem occurres when I run my project: 当我运行项目时,会发生此问题:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    system cannot be resolved
    at helloworld.main.main(main.java:7)

Java区分大小写,并且系统的正确拼写是System not system

   package helloworld;
   public class main {
       public static void main(String[] args) {
           System.out.println("hello world");
       }
   }

Changing your code to this should fix your Problem. 将代码更改为此应该可以解决您的问题。

A Little hint: Always fix your compilation problems. 一点提示:始终解决您的编译问题。 Eclipse show them to you with red underlined as you can see here: Eclipse向您显示,并用红色下划线显示,如下所示:

在此处输入图片说明

Eclipse also warns you if you try to start an porject within erros. Eclipse还警告您,如果您尝试在错误中启动一个对象。 (except your disabled it). (除非您禁用了它)。 Don't ignore those warnings. 不要忽略这些警告。

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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