Zulfi Khan wrote:
This is not a built in project. I am running Netbeans for the first time on ubuntu 18.04 so I am getting java.lang problem. Netbeans is not able to recognize the "String" class.
I don't know what the difference between a "built in" project and a non-"built in" project is supposed to be, but unless NetBeans is a lot different than I remember, every bit of user code visible to NetBeans must be in a NetBeans project.
And the project needs to have a JDK associated with it.
Normally when you install an IDE, it looks to see what JDKs and JVMs it can locate that are already in your system and will register one or more of them for use to compile and run NetBeans projects. If you installed NetBeans before installing a JVM, it may not have been able to do so, in which case I'd expect to see an error like what you are getting.
The other thing that can result in that sort of error is if you are not pointing to the root
directory of the JDK/JRE that you are trying to use. DO NOT point to the "bin" directory or one of the other sub-directories of the JDK that you downloaded and unzipped. For example, if I downloaded and unzipped the Oracle JDK jdk1.8.0_66
, I would unzip it (per Red Hat convention) into the /usr/java/ directory and the JDK location to plug into the IDE would be /usr/java/jdk1.8.0_66
In the case of OpenJDK, I cannot be so definite, because although OpenJDK is now pre-installed with Fedora Linux, I do all my professional work with the downloaded Oracle products (at least up until now). However, you will probably find that the openJDK equivalent for the /usr/java
directory on your machine is /usr/lib/jvm, so a generic path might be /usr/lib/jvm/java-11-openjdk
. Because of the "alternatives" feature of Linux, this may lead down one or more aliases (softlinks).