IntelliJ gives Fatal Error: cannot find java.lang package in classpath or bootclasspath

When I try to make a simple module in IntelliJ, it answers:

Fatal Error: Unable to find package java.lang in classpath or bootclasspath 
+113
classpath intellij-idea
Jun 15 '10 at 10:10
source share
7 answers

Somehow, the JDK language boxes were removed from the class path. All I had to do was repeat the original JSDK path.

Goto: File → Project Structure → Platform Settings → SDK Reapply the JSDK home path.

This added about 15 cans to the classroom path. They seem to be important for compilation.

+224
Jun 15 2018-10-06T00:
source share

File → Project Structure → Platform Settings → SDK, delete the existing SDK and add it again.

It works for me in IntelliJ 2017.3.

+13
Jan 13 '18 at 15:09
source share

This error occurred to me after I upgraded my version of JDK to jdk1.8.0_161 -
But the SDK project was still pointing to the old JDK 1.8.0_ 131

(The java update seems to erase the previous version).

Do this:

  1. In IntelliJ IDE go to File> Project Structure, from there:
  2. In Platform Settings > SDKs :
    Make sure that the valid JDK folder is specified in the Home path JDK field (if necessary, add a new entry, for example, jdk1.8.0_161).

  3. In Project Settings > Modules :
    Make sure that the SDK for the module is set to the same entry as in Platform Settings > SDKs

  4. Save and build again.
+4
Feb 14 '18 at 11:51
source share

This worked for me:

In the Build Tools > Maven > Runner > Environment Variables settings, set JAVA_HOME to your JDK home path.

Usually you want to use the same Java JDK that you use in IntelliJ. You can find this under Project Structure > Platform Settings > SDKs under the JDK home path .

eg. /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home

+3
Oct 28 '17 at 0:15
source share

After executing this answer, I found out that %LOCALAPPDATA%/IDEA/config/options/jdk.table.xml contains invalid entries. Fixed the problem with setting the JDK table.

0
Feb 11 '16 at 16:59
source share
  1. File> Project Structure
  2. JDK home path: PASTE_THE_JDK_LOCATION (as here in the "Project Structure Screenshot ")

  3. Build again

    Hurrah :)

0
May 26 '18 at 16:54
source share

I had 2 jdks, I had to delete the wrong one

0
Jul 02 '19 at 20:47
source share



All Articles