Ubuntu – Which JDK version is compatible with Netbeans on Ubuntu


I'm trying to install Netbeans on my Ubuntu. It was successfully installed but was unable to create new projects or new files. I have installed JDK 12 and then I removed it because I found here a solution that recommended removal of latest versions of JDK and set JDK 8 as default. I did what solution said but now I can't install JDK 8. It is showing me this error message:

E: Package 'oracle-java8-installer' has no installation candidate 

So I started searching on the Internet about the solution and I found that "Oracle Java (JDK) 8 Installer PPA (DISCONTINUED)".

What should I do now?

Best Answer

  • Open the terminal and type:

    sudo apt install openjdk-8-jdk openjdk-11-jdk

    Open NetBeans and check in Tools -> Options -> Java -> Nashorn tab that the default Java after where it says Java Platform is the same as the Java version which you want to use in your project.

    select Java Platform
    Apache NetBeans IDE 11.0 snap package

    You can add a new Java platform to the Java Platform dropdown menu by clicking the Manage Platform button to the right of the Java Platform dropdown menu.

    The apt package version of NetBeans in 18.04 is 10.0-3 and the snap package version of NetBeans in all currently supported versions of Ubuntu is 11.0. The version of NetBeans is the same as the Java version it targets, so NetBeans 11 targets Java 11 and NetBeans 12 targets Java 12, etc. Although JDK 8 is no longer maintained by Oracle, the openjdk-8-jdk package is still maintained in Ubuntu 16.04-21.10.

    If you tried to run a higher Java version in NetBeans than the NetBeans version, for example Java 14 in NetBeans 12, it would probably run, but there could be unexpected glitches with some of the plugins.