Issue
I am setting up a new machine after a long time.
I installed java using home brew:
brew install openjdk
In my .zshrc file I added:
export PATH="/usr/local/opt/openjdk/bin:$PATH"
Running 'java -version' gives the following output:
openjdk version "18.0.1.1" 2022-04-22 OpenJDK Runtime Environment Homebrew (build 18.0.1.1+0) OpenJDK 64-Bit Server VM Homebrew (build 18.0.1.1+0, mixed mode, sharing)
When I try to run the netbeans 13 installer pkg, I get the following message:
No Java Found NetBeans IDE cannot be installed. This software can be installed with Java 8 or newer. Please download and install the latest update of Java 8 from http://www.oracle.com/technetwork/java/javase/downloads/index.html and restart NetBeans installation.
I figured maybe I need to set the java home variable. But not sure where the correct location is. I tried:
export JAVA_HOME=/usr/local/Cellar/openjdk/18.0.1.1/libexec/openjdk.jdk/Contents/Home
But the error is still there.
Have I set my JAVA_HOME variable correctly ? How can I make sure that I have set the correct location ?
How can I get the Netbeans installer to install ? Why does it not see the JDK ?
EDIT:
If I run the following command:
/usr/libexec/java_home
Then I get the output:
The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for information on installing Java.
Solution
This is because I installed java via homebrew and did not see this message output in the end:
For the system Java wrappers to find this JDK, symlink it with sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
Run the command above to create the symlink, then netbeans installation proceeds. Wasn't necessary to set path or home. Set cpp flags because cpp is cool.
Even for other versions such as 11 it may be necessary to run a similar command. Homebrew mentions it, but unless you’re paying attention may not notice it at the end of the installation.
Answered By - Rahul Iyer
Answer Checked By - Willingham (JavaFixing Volunteer)