Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

    at di7.HelloWorld2.main(HelloWorld2.java:5)

 

反复检查了代码,发现并没有语法错误,但是就是运行出错,把代码复制到IntelliJ IDEA那边运行就能正常。

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

这是为什么呢?

 

在网上查了下,有些人说这个是因为

第一种说法:配置的问题:JDK版本更换了但是Eclipse里面却没有更改。

更改方法:

右击工程----->选择Build Path ----->configure build path见到下图

第二种说法:错误的原因是因为代码中没有指定​package,加上“package 包名;” 后再编译即OK。

 

但是都不适用于我这里的情况。

我把鼠标移到第11行,Exception in thread "main" java.lang.Error: Unresolved compilation problem:

原因好像是说,因为在我前一个名为HelloWorld的类也放在这个包里,而且那个类里的这个calcAvg()方法名一样,所以就导致了出错。

那么我就把这个方法名改了,课时为什么还是不行呢?

单独把这个class文件放到另一个包里,也是不能运行,为什么呢?

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

相关文章:

  • 2022-01-02
  • 2021-08-01
  • 2021-07-17
  • 2021-07-03
  • 2021-07-10
  • 2022-12-23
  • 2021-08-31
  • 2021-11-23
猜你喜欢
  • 2021-09-09
  • 2021-09-30
  • 2021-05-12
  • 2021-10-29
  • 2022-12-23
相关资源
相似解决方案