You have to install the full JDK, not only the JRE.

I had the same issue and solved by installing JDK.

Please use this link to download the latest JDK version 22.

Answer from MrDEV on Stack Overflow
Top answer
1 of 16
255

You have to install the full JDK, not only the JRE.

I had the same issue and solved by installing JDK.

Please use this link to download the latest JDK version 22.

2 of 16
210

After installing openjdk with brew and runnning brew info openjdk I got this:

==> openjdk: stable 21 (bottled) [keg-only]
Development kit for the Java programming language
https://openjdk.java.net/
/opt/homebrew/Cellar/openjdk/21 (600 files, 331MB)
  Poured from bottle using the formulae.brew.sh API on 2023-09-26 at 11:06:55
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/openjdk.rb
License: GPL-2.0-only with Classpath-exception-2.0
==> Dependencies
Build: autoconf ✔, pkg-config ✔
Required: giflib ✔, harfbuzz ✔, jpeg-turbo ✔, libpng ✔, little-cms2 ✔
==> Requirements
Build: Xcode (on macOS) ✘
Required: macOS >= 10.15 (or Linux) ✔
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

openjdk is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.

If you need to have openjdk first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk you may need to set:
  export CPPFLAGS="-I/opt/homebrew/opt/openjdk/include"

And from that I got this command here, and after running it I got Java working

sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
Top answer
1 of 5
5

It seems that you are missing Java environment variable to make your program work.

What you can try:

Solution 1

Try to run caver_analyst with the --jdkhome switch, followed by (I guess) the path to a valid JDK as suggested in your error message. It should solve your problem.

Solution 2

Usually, the path to Java must be defined in a JAVA_HOME environment variable. Yours is obviously not defined, so let's define it manually :

  1. Open a Terminal
  2. Go to your home directory with command cd
  3. Look for a file called ".zshrc" in this directory:
you@yourmac ~ % ls .zshrc
.zshrc
  1. If it does not exist i.e. if the command ls .zshrc gives you a "No such file or directory" message, create the file: touch .zshrc
  2. Get the path to Java and keep it somewhere : which java
  3. Open the newly created file (it's a hidden file so you will have to show hidden files. Alternatively, you can edit the file in command line with nano .zshrc)
  4. At the end of the file, add the following line : export JAVA_HOME="/Path/to/your/java/home" and replace /Path/to/your/java/home with the path that you got at step 5.
  5. Save, close the file, reboot your laptop.

This file will be automatically read and its instructions executed when you open your profile. The "export" instruction creates an environment variable. You can verify if it was successfully created with echo $JAVA_HOME, echo being a command to display something. The "$" in front of the variable tells echo to look for a variable.

I hope this helps, but if it doesn't, please don't hesitate to share the error messages and step where it fails here...

2 of 5
5

I had to

  • Install Java 8, eg
brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
  • add $JAVA_HOME to my ~/.zshrc
export JAVA_HOME='/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home'
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
  • remove any other jdk installs
ls /Library/Java/JavaVirtualMachines
sudo rm -rf NONJDK8.jdk

The 3rd bit is important! It did not work until I removed other-versioned jdks.

Discussions

Java Runtime not found | Apple Developer Forums
The operation couldn’t be completed. Unable to locate a Java Runtime. More on developer.apple.com
🌐 developer.apple.com
In Terminal getting error: The operation couldn't be ...
Got error 'The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt. Please visit http://www.java.com for information on installing Java.' when running command 'sudo apt install tor' java is installed so I don't know what the error is. More on discussions.apple.com
🌐 discussions.apple.com
June 15, 2023
[error] The operation couldn’t be completed. Unable to locate a Java Runtime
I’ve done the steps as suggested in this post: But I still get this error whenever I want to build an Android APK file from VS Code running on MacOS Ventura: ✖ Running Gradle build - failed! [error] The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit ... More on forum.ionicframework.com
🌐 forum.ionicframework.com
3
0
April 17, 2023
"Unable to locate a Java Runtime" error when building for Android on Mac
The ‘run android’ command kept failing on my Mac (running Big Sur) with the following error: Running Gradle build - failed! [capacitor] [error] The operation couldn’t be completed. Unable to locate a Java Runtime. I s… More on forum.ionicframework.com
🌐 forum.ionicframework.com
3
4
March 7, 2022
🌐
Mac Install Guide
mac.install.guide › java › unable-to-locate
Fix "Unable to Locate a Java Runtime" - Mac Install Guide
Fix the macOS Java error 'The operation couldn't be completed. Unable to locate a Java Runtime' on Mac. Troubleshoot Java on macOS, set JAVA_HOME, configure Mac PATH, and resolve java command not found errors.
🌐
Marco Gomiero
marcogomiero.com › posts › 2021 › kmp-no-java-runtime-error-xcode
How to fix the "Unable to locate a Java Runtime" error on Xcode with Kotlin Multiplatform - Marco Gomiero
December 27, 2021 - And that was the problem because sdkman “doesn’t expose” the JDK version to /usr/libexec/java_home. So I went back to the old and good manual way. Since the AdoptOpenJDK tap is deprecated, I tried the Temurin one and installed Java 11 and Java 8. brew tap homebrew/cask-versions brew install --cask temurin8 brew install --cask temurin11
🌐
Apple Community
discussions.apple.com › thread › 254929839
In Terminal getting error: The operation couldn't be ...
June 15, 2023 - java version "1.8.0_381" Java(TM) SE Runtime Environment (build 1.8.0_381-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode) Make sure you download the ARM64 version (under the green button) if you have an Apple M1 or M2 chip and not the intel version: If you are running on an M series system (ARM64), download the ... The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt.
🌐
Ionic Framework
forum.ionicframework.com › ionic framework › ionic vue
[error] The operation couldn’t be completed. Unable to locate a Java Runtime - Ionic Vue - Ionic Forum
April 17, 2023 - I’ve done the steps as suggested in this post: But I still get this error whenever I want to build an Android APK file from VS Code running on MacOS Ventura: ✖ Running Gradle build - failed! [error] The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit ...
🌐
Ionic Framework
forum.ionicframework.com › capacitor
"Unable to locate a Java Runtime" error when building for Android on Mac - Capacitor - Ionic Forum
March 7, 2022 - [capacitor] [error] The operation couldn’t be completed. Unable to locate a Java Runtime. I struggled for a while with it so just wanted to share what fixed it for me: Find the SDK path in Android Studio (Android Studio > Preferences…
Find elsewhere
🌐
Reddit
reddit.com › r/minecraft › unable to locate java runtime error
r/Minecraft on Reddit: Unable to locate Java runtime error
February 2, 2023 -

I have recently installed Minecraft off of the Xbox store on PC and every time I attempt to open it I get this error:

Unable to locate the Java runtime.
Error details: 0x00000000 - system: The operation completed successfully.
Filename on disk: javaw.exe
Path: C:\Users\ME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime\java-runtime-gamma\windows-x64\java-runtime-gamma\bin\javaw.exe
Exists: Nonexistent

I have tried multiple fixes but nothing seems to work. Is there anything I can do?

🌐
Reddit
reddit.com › r/javahelp › unable to locate java runtime that supports javac on macos monterey
r/javahelp on Reddit: unable to locate Java runtime that supports javac on MacOS Monterey
December 29, 2021 -

when I run javac -version in the terminal I just get this error:

The operation couldn’t be completed. Unable to locate a Java Runtime that supports javac.

can anyone help fix this I am trying to make a mod for Minecraft with mcp918

MacOS version: Monterey 12.1

Top answer
1 of 3
2
You need to install JDK.
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
Mac Help Forums
mac-help.com › forums › apple software › mac os
Terminal error: operation couldnt be completed. Unable to locate a Java Runtime that supports apt. Please visit http://www.java.com for information | Mac Help Forums
June 15, 2023 - How to fix the following error received in Terminal: "The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt. "Please visit http://www.java.com for information on installing Java." I went to the link, installed Java using the link, but still no-go. The command...
🌐
GitHub
github.com › withfig › fig › issues › 2778
bug: Installing Fig :: The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt. · Issue #2778 · withfig/fig
October 17, 2023 - Installing repo dependencies The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt. Please visit http://www.java.com for information on installing Java.
Author   withfig
🌐
Mac-Forums
mac-forums.com › apple computing products: › macos - apps and programs
I just installed Java, but it's not there.. | Mac-Forums | Fix Mac iPhone iPad | Buying Tips | iOS OS Help
April 20, 2023 - ... from google search: Temporarily turn off firewall or antivirus clients Active firewall or antivirus software may prevent Java from installing properly. Remember to turn your firewall or antivirus software back on when you have successfully completed the Java install.