且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java致命错误:无法在类路径或bootclasspath中查找包java.lang

更新时间:2023-11-18 23:22:16

问题来自IntelliJ bug(至少在版本14中存在)。
当JDK目录位于用户配置文件目录下时,会发生这种情况。例如,JDK位于此目录中(对于Windows):

The problem comes from IntelliJ bug (existing at least in version 14). It happens when your JDK directory is under the user profile directory. For example, JDK located in this directory (for Windows):

C:\Users\myuser\jdk1.8.0_20

C:\Users\myuser\jdk1.8.0_20

将存储在IntelliJ内部配置(文件'jdk.table.xml')中:

will be stored in IntelliJ internal configuration (file 'jdk.table.xml') as:

$ USER_HOME $ \jdk1.8.0_20

但您的%USER_PROFILE%在一些其他(非默认)位置。然后IntelliJ将查看错误的目录。

But your %USER_PROFILE% environment variable could point at some other (non default) location. Then IntelliJ will look at the wrong directory.

可能的修复:
在不同的目录安装JDK, strong>喜欢:

Possible fix: Install your JDK at different directory, which is outside your profile directory. Like:

C:\Programs\jdk1.8.0_20

然后注册此JDK以用于IntelliJ项目设置。

Then register this JDK for use in your IntelliJ project settings.