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");
}
}
"
If this problem occurs when importing a project in netbeans then try to create a new project then check the properties of your new created project and match those properties with the project that you imported in my case there was a difference between target of android package version.
run the compilation which fails with "Error:java: Fatal Error: Unable to find..." open build-log/build.log and search for rt.jar, you should find it in a block with a set of other JRE libraries and the directory which points to the file should be wrong
If you are not sure of your JDK path, run sudo update-java-alternatives -l to list these. Also, make sure you have set a Main Class as an entry point under Project Properties. See: stackoverflow.com/questions/20601845/…
After exiting netbeans edit the config file netbeans.conf
using
nano ~/netbeans-11.2/netbeans/etc/netbeans.conf
In the line netbeans_jdkhome
edit the path like
netbeans_jdkhome="/usr/lib/jvm/java-11-openjdk-amd64"
(Found at askubuntu.com)
I also had the same issue. Solved using manually setting the default jdk.
netbeans.conf
from <install_dir>/netbeans/etc
netbeans_jdkhome
propertyI am using Ubuntu 19.10
After a complete uninstall of my distros Netbeans version, I resorted to installing Netbeans 11 LTS version from the https://netbeans.apache.org/download/nb110/nb110.html into /usr/share/netbeans. This seems to have resolved the issues in the IDE. The program also seems to compile and run faster now.
I was having very similar problems with Netbeans IDE from the Ubunutu/Mint repositories which was still on version 10 the open JDK was version 11. I could not get the IDE to display without errors - but the program would compile and run from the command line fine.
If you're using Maven for the project and OpenJDK the reason could be the way that you define the source and target options in the maven-compiler-plugin. I had a little project build with JDK 1.8 and when I migrated it the maven compiler plugin show me that error. The solution that worked for me was change the format of the java version on the source and target parameters in maven-compiler-plugin definition:
Before:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
</compilerArguments>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
After:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>7</source>
<target>7</target>
<compilerArguments>
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
</compilerArguments>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With