Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 11 Required After Netbeans Update

Ubuntu 18.04.6 LTS

Netbeans updated (to version 19) over the weekend, and it is now completely broken. Whenever I try to start Netbeans, a pop-up shows up:

Pop-up Title: Java 11 or newer required Pop-up Desc: Cannot run on older versions of Java than Java 11. Please install Java 11 or newer or use --jdkhome switch to point to its installation directory.

The pop-up can be dismissed but Netbeans will not open.

I do not want to use Java 11 (currently using Java 8) because some of my dependencies do not support it. What is the best way to fix this? Can I roll back this unwanted update? How do I prevent Netbeans from being updated in the future?

UPDATES: It seems rolling back Netbeans is not an option. As a workaround, I installed Java 11, which has not yet fixed the problem.

  1. Installed Java 11 using: sudo apt-get install openjdk-11-jdk Netbeans still fails. Pop-up says requires Java 11.

  2. Set default java to openjdk11 using:

    sudo update-alternatives --config java Netbeans still fails. Pop-up says requires Java 11.

  3. I checked the jdkhome line in netbeans.conf, and found 3 instances of this file:

    /etc/netbeans.conf

/snap/netbeans/84/netbeans/etc/netbeans.conf

/snap/netbeans/80/netbeans/etc/netbeans.conf

All three files have the jdkhome line commented out using a #. I can only edit the /etc/netbeans.conf file, the other 2 are uneditable (even using sudo nano [file]).

  1. Set jdkhome in /etc/netbeans.conf file using:

    sudo nano /etc/netbeans.conf

Tried: netbeans_jdkhome="/usr/lib/jvm" Netbeans fails to launch.

netbeans_jdkhome="/usr/lib/jvm/java-11-openjdk-amd64" Netbeans fails to launch.

netbeans_jdkhome="/usr/lib/jvm/java-11-openjdk-amd64/bin" Netbeans fails to launch.

  1. Attempted to set JDK by running Netbeans from terminal and using the --jdkhome flag, but this did not work.

/snap/netbeans/current/netbeans/bin/netbeans --jdkhome /usr/lib/jvm/java-11-openjdk-amd64 Throws a warning : "Warning - An instance of the program cannot access specified user directory. This is a serious problem that may prevent the program to function properly. Make sure is writable. Click OK to continue in spite of previous error."

Clicking OK gives an error:
java.io.FileNotFoundException: /snap/netbeans/84/netbeans/bin/lock (Read-only file system)

Running the prior command with sudo gives the exact same result. Java 11 and Java 8 are both installed in the same place (/usr/lib/jvm), so it is beyond me why it could access Java 8 JDK just fine a week ago, and now "cannot access specified user directory".

UPDATE 2: I went back to running netbeans from terminal using the --jdkhome switch and finally found the magic words...sort of:

XYZ@XYZ:/snap/netbeans/current/netbeans/bin$ netbeans --jdkhome /usr/lib/jvm/java-11-openjdk-amd64 WARNING: package com.apple.eio not in java.desktop

The ^above^ command successfully starts Netbeans, but it doesn't FIX Netbeans, because opening Netbeans from the desktop icon still fails with the original error. I have to start it from Terminal with the above command.

I tried changing Tools>Options>Java options to use Java 11 or 17 with no effect (even though I still plan to use Java 8 for dev).

like image 818
backclipped Avatar asked Oct 29 '25 02:10

backclipped


2 Answers

open netbeans.conf file in notepad, e.g. mine is situated in C:\ides\netbeans\etc\netbeans.conf and set netbeans_jdkhome variable on your own , e.g. netbeans_jdkhome="C:\Program Files\Java\jdk-22" save the file , launch the IDE and you are done.

like image 127
CodeToLife Avatar answered Oct 31 '25 17:10

CodeToLife


I'm using Windows and I had the same issue just now. I uninstalled Netbeans-19, then manually installed JDK-20:

https://www.oracle.com/java/technologies/downloads/#jdk20-windows

I then reinstalled Netbeans-19 pointing the installer to the JDK-20 folder and it worked fine.

like image 37
BigBadMe Avatar answered Oct 31 '25 16:10

BigBadMe