14

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 http://www.java.com for information on installing Java.

The operation couldn’t be completed. Unable to locate a Java Runtime that supports (null).
Please visit http://www.java.com 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!

4
  • It seems that your Java binary cannot be found... May I suggest adding to output of the following commands in a Terminal ? "java -version", "echo $JAVA_HOME" and "echo $JDKHOME"
    – FloT
    Commented Mar 29, 2021 at 15:29
  • Hey @FloT, I did as you suggested, but it still does not work. The output of java -version is: java version "16" 2021-03-16 Java(TM) SE Runtime Environment (build 16+36-2231) Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)
    – amiro
    Commented Mar 29, 2021 at 18:18
  • Yes @amiro, I wasn't expecting this to make to stuff work, only to give some ideas of what goes wrong :-) does "echo $JAVA_HOME" shows a path ?
    – FloT
    Commented Mar 29, 2021 at 20:13
  • Hey @FloT, no path, the command does not return anything.
    – amiro
    Commented Mar 30, 2021 at 0:48

5 Answers 5

3

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...

4
  • 5
    echo $JAVA_HOME produces "/usr/bin/java" but I still have the error
    – ekkis
    Commented Aug 4, 2021 at 5:29
  • The proposed solution does not seem to work.
    – zell
    Commented Oct 1, 2021 at 21:14
  • zell which one did you try ? What error did you get ? May I suggest opening another question with the exact steps you followed and the error you got ? @ekkis what is your Java version ? Per their website, you need a java 1.8. I've tried with Java 16 and got an error, but could make it work with Java 11.
    – FloT
    Commented Oct 7, 2021 at 16:45
  • 1
    openjdk 11.0.12 2021-07-20
    – ekkis
    Commented Oct 8, 2021 at 17:29
3

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.

2

this worked for me:

$ brew reinstall adoptopenjdk8

and adding this to .zshrc

export JAVA_HOME=$(/usr/bin/java)

and then run

$ source ~/.zshrc
1

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.

3
  • 1
    This is what worked for me as of 2023
    – Mariusz
    Commented Oct 21, 2023 at 10:05
  • I've got export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-18.0.1.1.jdk/Contents/Home" in my .zshrc. As far as the second export command is concerned, what does the -v 1.8 refer to? Does it have to be 1.8? Or does it have to match the version of the JDK installed on the system? Commented May 31 at 6:13
  • It has to match the JDK version
    – ehacinom
    Commented Jun 17 at 16:15
0

I 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:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .