[英]Eclipse: "The import java.io cannot be resolved"
I have several Android projects in Eclipse, and all is fine, except one (a library) that can not resolve any imports.我在 Eclipse 中有几个 Android 项目,一切都很好,除了一个(库)无法解析任何导入。
The java.io imports do resolve fine in other Android projects in the same workspace, and previously (I haven't used it for over a year) this library worked fine, too. java.io 导入在同一工作区中的其他 Android 项目中确实可以很好地解决,并且以前(我也没有使用它超过一年)这个库工作得很好。
Any ideas?有任何想法吗?
Check two things 检查两件事
Eclipse preferences Eclipse首选项
Java
-> Installed JREs
Java
- > Installed JREs
Project build path 项目构建路径
Properties
-> Java Build Path
Properties
- > Java Build Path
libraries
folder whether the JRE System Library is present and ... libraries
文件夹中是否存在JRE系统库并且... Add library
-> JRE System Library
and then select the correct one (from an installed JDK). Add library
- > JRE System Library
添加它,然后选择正确的(从已安装的JDK)。 The following worked for me: 以下对我有用:
OR 要么
I am using Maven an this is what I did to re-solve --> 我正在使用Maven这是我所做的重新解决 - >
I was missing the JRE Systems Library in my Project Tree. 我错过了项目树中的JRE系统库。 And navigating to Projects' Build Path and 'Add(ing) Library' worked!
导航到Projects的Build Path和'Add(ing)Library'工作!
I just ran into this problem with Eclipse 2022-6 and java-17-openjdk-amd64.我刚刚用 Eclipse 2022-6 和 java-17-openjdk-amd64 遇到了这个问题。 I just appeared during editing in another file, the same code had worked before.
我刚刚在另一个文件中编辑时出现,相同的代码之前已经工作过。
For me, all settings were correct and none of the above tricks worked.对我来说,所有设置都是正确的,上述技巧都没有奏效。 What I then did was completely removing the import command
import java.io.Closeable;
然后我所做的是完全删除导入命令
import java.io.Closeable;
, saving the file, adding the same import command back at the same place, and saving again. ,保存文件,在同一位置添加相同的导入命令,然后再次保存。 The error disappeared.
错误消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.