I recently tried to install NetBeans 8.1 on my fresh installation of Ubuntu 16.04, and I ran in to some difficulties. The first of which is that OpenJDK cannot be easily found in the new Ubuntu Software application. To install OpenJDK 8, you will need to open terminal and use the command “sudo apt-get install openjdk-8-jre openjdk-8-jdk”.
The next issue was the default location the NetBeans installer chooses for the JDK is in “/usr”, but if left as so the installer will later say “The JDK is missing” and NetBeans will fail to start due to being “Unable to locate Java”.
The easiest fix is to simply reinstall NetBeans and specify the proper path for the JDK, which in the case of OpenJDK 8 is: “/usr/lib/jvm/java-8-openjdk/amd64/”. Afterwards, the installer should complete without error and NetBeans can be run.
Alternatively if you have already installed NetBeans and want to fix the installation, you will need to provide the above path in two locations. First locate the folder “etc” within the NetBeans installation folder and open the file “netbeans.conf”. Find the line with “netbeans_jdkhome=” and replace the path there with “/usr/lib/jvm/java-8-openjdk/amd64/”. Next you can fix the desktop shortcut (if you care). Open the shortcut file in a text editor or by right-clicking it and selecting “properties”. At the end of the “Command” line, add the string “–jdkhome /usr/lib/jvm/java-8-openjdk/amd64/”. The desktop shortcut should now be fixed, as well as the Unity dash launcher.
Note as of Ubuntu 16.04.1: It seem the above path has changed to “/usr/lib/jvm/java-8-openjdk-amd64/”. Check to see which folder exists on your system before setting the configuration.
If you are still having difficulty or are using a different distribution, you should use the command “locate javac” to find the correct JDK path for your system.