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...
Answer from Flow on Stack ExchangeIt 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...
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.
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.
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