4

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).

4
  • 1
    I wonder if you had configured your NetBeans installation to use an external JDK for its own execution rather than relying by default on its own internally bundled JDK? NetBeans is itself a Java app, and needs a JDK to operate. The JDK used to run NetBeans does not have to be the same JDK used to build and execute your Java project. Commented Sep 11, 2023 at 20:28
  • The bad news is that with NetBeans 19 you have no choice but to upgrade to a JDK >= 11 because the Release Notes state that: "The Apache NetBeans 19 binary releases require JDK 11+...". The good news is that you can still build your projects using Java 8 if you use JDK11+. That said, it would be preferable for NetBeans to refuse to update itself if it couldn't find an appropriate JDK, rather than blindly updating and then refusing to start because the default JDK is invalid. But not a big deal really, and there's no need to roll back. Commented Sep 12, 2023 at 18:48
  • 1
    @BasilBourque how would I configure that (other than with the netbeans.conf file)? I did not setup this dev environment. Commented Sep 13, 2023 at 20:07
  • 1
    @skomisa exactly. All I wanted was the option to delay the update since I did not have the prereqs. Commented Sep 13, 2023 at 20:08

5 Answers 5

7

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried this method, but it has not worked. Details on the OP. Confusingly, the Terminal command <netbeans --jdkhome /usr/lib/jvm/java-11-openjdk-amd64> works, but changing the netbeans.conf line to <netbeans_jdkhome="/usr/lib/jvm/java-11-openjdk-amd64"> does not work.
@backclipped I run the NetBeans on win10 now. But recently have had almost a similar problem with jdev ide. I did so. Got in C:\Users\yourUser\AppData\Roaming\JDeveloper and moved that JDeveloper with all settings to desktop as a backup to roll things back if any. Then launched jdev and it has opened by creating a new settings folder/ Probably on Ubuntu there is a same way there/
3

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.

Comments

2

Although NetBeans itself needs JDK 11, I think you can still build and run JDK 8 for your projects.

See Overview of JDK 8 Support in NetBeans IDE.

I also found this other StackOverflow question about pointing NetBeans at a particular JDK, in case you run into any trouble: How can I set the JDK NetBeans runs on?

2 Comments

Installing JDK 11 did not fix the issue, even after the netbeans.conf file was updated. Please see post updates.
Perhaps look at this question for help with that. It sounds like the snap package is complicating things.
2

use --jdkhome switch Steps:

  1. Right click on Netbeans Shorcut
  2. Select Properties
  3. Add --jdkhome switch to Target

enter image description here

1 Comment

I am using Ubuntu, and it doesn't appear that there is an analogous shortcut option. I can use the --jdkhome switch to open Netbeans via the Terminal. Unfortunately this method always shows the Java project as having "Project Problems" because "Java Platform Does Not Support FX", which I then resolve by choosing the Java 1.8 platform.
1

Only the NetBeans binaries need the JDK 11, it doesn't effect your projects!

The Runtime JDK NetBeans uses does not influence the JDK range projects can use. - Release Notes

1 Comment

Installing JDK 11 did not fix the issue. Please see post updates.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.