Software⏱️ 4 min read📅 2026-06-04

How to Fix: IntelliJ gives Fatal Error: Unable to find package java.lang in classpath or bootclasspath

IntelliJ error unable to find package java.lang in classpath or bootclasspath

Quick Answer: Check if Java is properly installed and configured, ensure the JDK is added to the project's classpath.

IntelliJ IDEA throws a Fatal Error: Unable to find package java.lang in classpath or bootclasspath when it's unable to locate the Java Standard Library, which is required for many built-in and third-party plugins. This error affects users who are trying to create simple modules in IntelliJ.

This error can be frustrating because it prevents users from completing their tasks efficiently. Fortunately, there are steps you can take to resolve this issue.

🔍 Why This Happens

  • The primary reason for this error is that the Java Standard Library is not included in the classpath or bootclasspath of your project. This can happen if you're using a custom classpath or if the library is not properly configured.
  • An alternative reason for this error could be that there are duplicate classpaths or conflicting libraries in your project, which can cause IntelliJ to struggle with locating the required packages.

🔧 Proven Troubleshooting Steps

Configuring the Classpath

  1. Step 1: Step 1: Open the Run/Debug Configurations dialog box by pressing Alt+F9 (Windows/Linux) or Cmd+Shift+R (Mac).
  2. Step 2: Step 2: Select the 'Modules' tab and click on the gear icon next to the project you're working in. This will open the 'Module Settings' dialog box.
  3. Step 3: Step 3: In the 'Dependencies' section, check that the Java Standard Library is included in the classpath by looking for the 'jre' or 'jdk' library under 'Libraries'. If it's not present, add it manually by clicking the '+' button and selecting the correct library version.
  4. Step 4: Step 4: Save your changes and try running your project again.

Using the Maven or Gradle Build Tool

  1. Step 1: Step 1: If you're using a Maven or Gradle build tool, make sure that the Java Standard Library is included in your project's dependencies. You can do this by adding the following configuration to your pom.xml (Maven) or build.gradle (Gradle):
  2. Step 2: Step 2: For Maven, add the following dependency to your pom.xml file: jakarta.platformjakarta.platform18.1
  3. Step 3: Step 3: For Gradle, add the following configuration to your build.gradle file: implementation 'jakarta.platform:jakarta.platform:18.1'
  4. Step 4: Step 4: Save your changes and try building your project again.

🎯 Final Words

By following these steps, you should be able to resolve the Fatal Error: Unable to find package java.lang in classpath or bootclasspath in IntelliJ IDEA. Remember to always check your classpath and dependencies to ensure that they're properly configured.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions