2

At first we are talking about MacOS Big Sur.

Until today I had the folder jdk-16.0.2.jdk with all its content in /Library/Java/JavaVirtualMachines which I downloaded from Oracle at a certain point in time. It worked fine and java -version respondeds with the corresponding version and Netbeans worked fine along with Tomcat. That was my java installation. Downloaded the .tar from Oracle and copy to that folder.

Today I am trying to migrate to openJDK so I did the same. I downloaded "openjdk-17.0.2_macos-aarch64_bin.tar" from java.net. Just the same procedure. Untar the files and copy to /Library/Java/JavaVirtualMachines (And moving the old Java to Desktop.

When I try % java -version I get:

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

I resist a little to the idea of installing JAVA via homebrew (Which I use for other purposes) since I'd like to have the very same version in my dev environment (My Mac in this case) and in my production environment (Rocky Linux 8).

Any idea?

Thank you very much in advance.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
mdev
  • 472
  • 7
  • 18
  • Does this answer your question? [How to brew install java?](https://stackoverflow.com/questions/65601196/how-to-brew-install-java) The second answer details how to install a specific openjdk version using brew. – Cornelius Roemer Aug 12 '22 at 19:56

1 Answers1

2

If you have not yet updated your %JAVA_HOME% environment variable, that must be pointed to your new installation. Your installation path looks correct. Here is a thread about setting the environment variable: https://stackoverflow.com/a/65162351/1656012

Trenton Telge
  • 478
  • 3
  • 17
  • 1
    It is weird but never seted JAVA_HOME before. Actually it was blank. But your solution worked fine in DigitalOcean Rocky Linux. The problem I was having was with Yum openJDK package with an error like "it was compiled with a newer version". But I installed a bundle from Java.net and worked fine. Guess I will keep the Oracle version in my mac. – mdev Feb 18 '22 at 23:21