Netbeans does not start on fresh Ubuntu 18.04 installation

After fresh Ubuntu 18.04 installation and afterwards a netbeans installation, netbeans does not start. netbeans was installed with

sudo apt install netbeans

some other java programms (at least Eclipse) do not start too.

when starting netbeans from commandline the JVM prints folowing WARNINGS:

➜  ~ netbeans
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.netbeans.ProxyURLStreamHandlerFactory (file:/usr/share/netbeans/platform18/lib/boot.jar) to field java.net.URL.handler
WARNING: Please consider reporting this to the maintainers of org.netbeans.ProxyURLStreamHandlerFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
➜  ~ 

Solution 1:

Ubuntu's repository still has Netbeans 8.1 but JDK 11. So I've downloaded Netbeans 8.2 from Netbeans Website

After downloading Netbeans 8.2, follow these steps:

sudo apt autoremove netbeans
cd Downloads
sudo chmod +x netbeans-8.2-linux.sh
./netbeans-8.2-linux.sh

and follow on screen instructions. Import settings and launch the netbeans from app drawer.

Also if you have any package with name as JDK 8, just remove it. You can find the packages installed by using

sudo apt list --installed

and remove all packages with name as openjdk-8- by using,

sudo apt autoremove <package_name>

For Installation of Netbeans 9.0 see here.

Solution 2:

I was able to get it working by installing and setting JDK8 as default.

I followed the instructions on this website: https://linuxconfig.org/how-to-install-java-on-ubuntu-18-04-bionic-beaver-linux

specifically:

Adding the PPA repository:

sudo add-apt-repository ppa:webupd8team/java
sudo apt update

Install Java 8, and set as default:

sudo apt install oracle-java8-set-default

I was able to install using the netbeans .sh file installed after that

Solution 3:

I was able to solve this by running sudo update-alternatives --config java and then selecting the java-8 option rather than the default java-11. You will need to have the java-8 openjdk package still installed for this to work though.