Supergamer5465
Supergamer5465

Reputation: 77

In NetBeans 12.0 I get the error cannot access java.lang

I know there are very many questions exactly like this, but I have tried various things and still have no idea what to do. I started learning java very recently and was just able to print "hello world" with a .java file using a text editor. That was when I decided to get an IDE and I downloaded NetBeans 12.0. Once netbeans was ready, I clicked "new project" and chose "Java with Maven" and "Java application". Once I finished setting up the project, I right clicked the package and made a new main class. However, next to "package com.mycompany.qwerty" in the file there was a red exclamation mark symbol where it shows the line numbers. When I put my mouse over it, it said "Cannot access java.lang Fatal error: unable to find package in classpath or bootclasspath". I have absolutely no idea how to fix this since I have never used NetBeans before. I have tried reinstalling netbeans several times and the same thing occurs. I have jdk 11.0.8 as well. How would I resolve this issue?

Upvotes: 0

Views: 3450

Answers (1)

Supergamer5465
Supergamer5465

Reputation: 77

After reading sorifiend's comment, I looked up how to change the file path for jdk. In a file called netbeans.conf the variable called netbeans_jdkhome was just /usr or something and I changed it to /usr/lib/jvm/java-1.11.0-openjdk-amd64 (I have linux) and then the problem was completely fixed.

Upvotes: 2

Related Questions