Myeclipse报错:The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from

JDK从1.7切换到1.8,Myeclipse10.0导入之前运行正常的工程提示如下错误:

Description Resource    Path    Location    Type
The project was not built since its build path is incomplete. Cannot find the class file for java.lang.reflect.AnnotatedElement. Fix the build path then try building this project  analysis_system     Unknown Java Problem
Description Resource    Path    Location    Type
The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from required .class files  SpringContextsUtil.java /analysis_system/src/main/java/cn/geekview/analysisSystem/utils line 1  Java Problem

解答:

When using JDK 8 and an IDE with its own compiler, like Eclipse, you have to update the IDE to a version with Java 8 support, even if you are not using the newer Java 8 features.

The reason is that the compiler must be able to load the newer class files of the JRE in order to compile your software which references these classes.

Sometimes you can get away with an older compiler when it ignores the newer version number of the class files. But some types will confuse older class file parsers as they use new features, notably AnnotatedElement, which now has default methods, and Map.Entry, an interface which now has static methods.

It seems that Eclipse does not make a difference between references for which no class file could be found and class files it failed to read when saying “«classname» cannot be resolved”.

实际上就是Myeclipse的版本太低不支持JDK1.8,所以更新开发工具的版本即可解决,我个人切换到IDEA上运行就解决这个问题了!

或者

也就是说, java.lang.CharSequence是rt.jar包中的一个雷,在JVM7.0中是没有问题的,但是在JVM8.0中就会出问题。

有了这个解释就好办了,删除掉之前装好的JDK8,重新下载个低版本的JDK7,问题解决!

猜你喜欢

转载自blog.csdn.net/mingyuli/article/details/82461674