答案 0 :(得分:1)
每个错误都是编译错误,编译器会告诉您项目的构建路径中没有类。当然所有这些都是JDK中包含的类。
看起来Eclipse丢失了工作区主JRE,这有时是由于Java自己在一夜之间在线更新,并删除旧的JDK安装。要解决此问题,请恢复工作区JRE并将其分配给项目。
恢复JRE:转到
Window>Preferences>Installed JREs
remove any JRE you have (you probably have one in a red state)
add a new Workspace JRE and make it the default:
Click on Add>Standard VM> As Java home, use the main folder where your JDK is installed.
将其重新分配给您的项目:
Right click on Project>Properties>Java Build Path>Libraries
Remove the current JRE library (if it is in a red state),
Re-assign the JRE:
Select Add Library>JRE System Library>and use the workspace default.
单击Apply,clean并构建项目,编译应该成功。