Netbeans IDE 11 cannot access java.lang Fatal Error: Unable to find package java.lang in classpath or bootclasspath

Ahmad Anis picture Ahmad Anis · Sep 28, 2019 · Viewed 11.8k times · Source

I downloaded netbeans ide 11 and tried to do a sample hello world project but it is giving me error "cannot access java.lang Fatal Error: Unable to find package java.lang in classpath or bootclasspath" I tried some solutions from stack overflow but didnt worked.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

/**
 *
 * @author ahmad
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println("Hello");
    }
    
}

Main error is " cannot access java.lang Fatal Error: Unable to find package java.lang in classpath or bootclasspath

"enter image description here

Answer

Sabuj Das picture Sabuj Das · Jan 22, 2020

I also had the same issue. Solved using manually setting the default jdk.

  1. open the netbeans.conf from <install_dir>/netbeans/etc
  2. set the JDK home path for netbeans_jdkhome property

I am using Ubuntu 19.10