Ubuntu – Can’t using Netbeans 10.0 after installing from repository on Ubuntu 18.04

javajdknetbeans

After installing JDK 11, I installed Netbeans from the repository. After all the processes, I finally installed successfully but when I created a simple program or opened the sample programs in this software, but there are many failures here.

Example: When I created a new java program,failures are:

cannot access java.lang fatal error unable to find package java.lang in classpath or bootclasspath 

in the line shows the package's name and

cannot find symbol class String

picture1
picture2

I think there is something wrong in the installation. How do I solve the issue?

Best Answer

Check that the java platform was correctly configured when you installed Netbeans.

In my case, during the installation process, there was a box for entering the path to the Java SDK, which defaulted to /usr (which is probably wrong). I failed to check that, and ended up having a wrongly configured JDK.

You can check this by going to Tools > Java Platforms in Netbeans. If the JDK platform says something like "Error: the specified folder does not contain a Java platform" then that's your problem.

In order to fix this you can either reinstall netbeans (and pick the correct path this time)

OR

Edit the config file (exit netbeans first), in my case:

nano ~/netbeans-11.2/netbeans/etc/netbeans.conf

find the line with netbeans_jdkhome= and edit the path. Example:

netbeans_jdkhome="/usr/lib/jvm/java-11-openjdk-amd64"

save the file, and start Netbeans. With luck, it should work now.