Installing Netbeans 9.0:
For natively installing Netbeans v8.2, See Karel's answer.
Original Answer:
Java seems to be quite broken currently under 18.04. This can create problems with Netbeans as well as Eclipse. So, I'll suggest not to install Java from Ubuntu's repository.
If you want JDK as well as Netbeans first of all remove Java completely from your system. Then download NB+JDK from here.
I assume that downloaded files go to Downloads
and downloaded file name is jdk-8u111-nb-8_2-linux-x64.sh
. Use below commands to install Netbeans and JDK 1.8.
Navigate to the folder(Downloads) containing file using
cd ~/Downloads
Make file executable(if already not) using
chmod +x jdk-8u111-nb-8_2-linux-x64.sh
Finally run it using
./jdk-8u111-nb-8_2-linux-x64.sh
Follow on screen instructions to complete installation.