IntelliJ gives Fatal Error: Unable to find package java.lang in classpath or bootclasspath
Somehow the JDK language jars were removed from the classpath. All I had to do was reapply the JSDK home path.
Goto: File -> Project Structure -> Platform Settings -> SDKs Re-apply the JSDK home path.
Doing this added about 15 jars to the classpath. Apparently these are important for compiling.
File -> Project Structure -> Platform Settings -> SDKs, remove existing SDK and add it again.
Works for me in IntelliJ 2017.3.
This error happend to me after i've updated my JDK version to jdk1.8.0_161 -
But the project's sdk was still pointing to the old jdk 1.8.0_131
(Seems that updgrading java causing the previous version to be wiped).
Do this:
- In the IntelliJ IDE go to File > Project Structure, from there:
Within
Platform Settings > SDKs
:
Make sure that the JDK Home path field is pointing to a valid JDK folder (add a new entry if needed e.g. jdk1.8.0_161).Within
Project Settings > Modules
:
Make sure that the Module SDK is set to the same entry you picked in thePlatform Settings > SDKs
- Save & Build again.