How to solve “Unable to locate a Java Runtime that supports” error?
I am trying to run a java-based program called Caver analyst on MacOS BigSur 11.2.3
When I click on the Unix executable file, a terminal window pops up with the following message:
/Users/amir/Desktop/caver_analyst2/bin/caver_analyst ; exit;
The operation couldn’t be completed. Unable to locate a Java Runtime that supports (null).
Please visit for information on installing Java.
The operation couldn’t be completed. Unable to locate a Java Runtime that supports (null).
Please visit for information on installing Java.
Found jdkhome=
Cannot find java. Please use the --jdkhome switch.I downloaded the latest Java version (15.0.2) and, as recommended in similar questions, added its path to the .config file, however, nothing works.
Thanks for the help!
44 Answers
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 :
- Open a Terminal
- Go to your home directory with command
cd - Look for a file called ".zshrc" in this directory:
you@yourmac ~ % ls .zshrc
.zshrc- If it does not exist i.e. if the command
ls .zshrcgives you a "No such file or directory" message, create the file:touch .zshrc - Get the path to Java and keep it somewhere :
which java - 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) - 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. - 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...
4I think I ran into a similar problem with another java application The java app I was trying to run was using /usr/libexec/java_home to set java home So even though I had $JAVA_HOME pointing to a working Java SDK installation that app refused to run.
So there's a couple options you can try:
- Try to install GraalVM with these instructions: . It tells you how to integrate with /usr/libexec/java_home
- You can manage your java installations (among others) with asdf and use the asdf java plugin to enable /usr/libexec/java_home integration (you must enable first before installing java or you need to reinstall after configuring):
this worked for me:
$ brew reinstall adoptopenjdk8and adding this to .zshrc
export JAVA_HOME=$(/usr/bin/java)and then run
$ source ~/.zshrc I found out that the issue here is having the regular runtime versus a developer kit (JRE).
In theory, no end-user application should need the JDK (it's supposed to be for developers), but as we can see, that's not how it works in practice...
Also note that since Oracle has imposed stricter licensing terms on Java, you should probably download something more open (an "OpenJDK"), like Amazon's Coretto.