Java 致命错误:无法在类路径或引导类路径中找到包 java.lang [英] Java Fatal Error: Unable to find package java.lang in classpath or bootclasspath

查看:63
本文介绍了Java 致命错误:无法在类路径或引导类路径中找到包 java.lang的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误

Error:java: Fatal Error: Unable to find package java.lang in classpath or bootclasspath

Error:java: Fatal Error: Unable to find package java.lang in classpath or bootclasspath

在 IntelliJ 中,当我尝试构建/编译 任何 项目时.这里应该说明的是,NetBeans、Eclipse 甚至 javac 命令行都可以毫无错误地编译、构建和执行相同的项目.这就是为什么我怀疑问题出在 IntelliJ 上,所有其他 IDE 都运行良好.

in IntelliJ when I try to build/compile any project. Something that should be stated here is that NetBeans, Eclipse and even the javac command line can compile, build, and execute the same project without errors. This is why I suspect that the problem lies with IntelliJ, all other IDEs work well.

在 IntelliJ 中我已经:

  • 重新启动,重新安装
  • 使缓存无效/重新启动
  • 删除/重新添加了 Project JDK 中的 JDK
  • 在平台设置中删除/读取JDK
  • 重建/重新编译

    In IntelliJ I already:

  • Restarted, reinstalled
  • Invalidate Caches / restarted
  • Deleted / readded the JDK in Project JDK
  • Deleted / readded the JDK in Platform Settings
  • Rebuild / recompile

    在 Windows 中我已经:

  • 已删除/重新安装的 Java SDK
  • 删除/重新添加系统变量上的 JAVA_HOME、PATH 和 CLASSPATH
  • 在用户变量上尝试了上述方法
  • 删除并重新安装 IntelliJ IDEA

    In Windows I already:

  • Deleted / Reinstalled Java SDK
  • Deleted / Readded the JAVA_HOME, PATH and CLASSPATH on System Variables
  • Tried the above on User Variables
  • Deleted and reinstalled IntelliJ IDEA

    我已经在互联网上搜索过类似的问题,在 Stack Overflow 上我发现:
    问题#1 |问题#2 |问题#3 |问题#4 |问题#5
    和 30 多个网站,并尝试了每一个答案......
    此处您可以看到我上次尝试构建/编译时的 IntelliJ 项目结构

    出现此错误时,我使用的是 Java 1.8,几个小时后,我安装了 Java 1.7,项目运行良好.也许 IntelliJ 不支持 Java 1.8?

    I already seached for issues like this on the Internet, here on Stack Overflow I found:
    Question #1 | Question #2 | Question #3 | Question #4 | Question #5
    And 30+ sites, and tried every answer...
    Here you can see my IntelliJ Project Structure the last time that I tried to build/compile

    I was using Java 1.8 when I got this error, after some hours, I installed Java 1.7 and the project worked fine. Maybe IntelliJ doesn't support Java 1.8?

    无论如何,如果有人知道让 Java 1.8 与 IntelliJ 一起工作的方法,那就太好了.

    Anyway, it would be great if anyone knew a way to make Java 1.8 work with IntelliJ.

    推荐答案

    问题来自 IntelliJ 错误(至少在版本 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:Usersmyuserjdk1.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 安装在不同的目录中,该目录在您的配置文件目录之外. 喜欢:

    C:Programsjdk1.8.0_20

    然后注册此 JDK 以在您的 IntelliJ 项目设置中使用.

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

    这篇关于Java 致命错误:无法在类路径或引导类路径中找到包 java.lang的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆