Netbeans Apache 12.2 on macOS Big Sur only runs properly as super user

Viewed 559

When running as a normal user, if you click on Netbeans->Preferences the window will open, shake, flash, freeze, and not let you do anything. The same thing happens with the Tools->Plugins. Running as super user it works perfectly. I have cleaned up all NetBeans related files. You can see it in action here.

It's useless as it is.

3 Answers

Ive found a partial workaround for this.

You need to setup the OS not to open new documents as new tab.

Go to the Apple Menu, select System Preferences > General. In the Prefer tabs when opening documents option, select "never".

Then restart Netbeans and try to open Netbeans preferences.

If you don't want a system-wide change, you can set the following setting. It should affect only applications running on JDK, run this in terminal:

defaults write net.java.openjdk.cmd "AppleWindowTabbingMode" never

It turns out that is a problem related to the AppleWindowTabbingMode settings. I was using "always", since I want that apps like Finder and other use new tabs rather than new windows.

This settings worked fine with NetBeans since Catalina. So I reset the behavior to "never" only for NetBeans, with the follow command

defaults write net.java.openjdk.cmd "AppleWindowTabbingMode" never

With this setting NetBeans works finally fine!

Sources: apparently, it's a bug, please see here and corresponding JDK bug.

Also, it's not a problem with NetBeans only. It affects AndroidStudio also see here for example:

If you choose to run it as root, here's what I use:

#!/bin/bash
APP=/Applications/NetBeans/Apache\ NetBeans\ 12.2.app/Contents/MacOS/netbeans
COMPLAINT="Netbeans must run as %U because of bugs in the UI implementation :{"
PROMPT=$(echo -e "${COMPLAINT}\nPlease enter your login password for privilege escalation:")
sudo -p "${PROMPT}" -b -s "${APP}"

This lets me limp by with a recent JDK (15.0.2) which placates the corresponding NetBeans (12.2, as you can see from the code). The -b option tells sudo to run the app in the background, which in this case means simply that the Terminal in which you ran this script will not be polluted with JDK whinging about "illegal reflective access".

Related