How do you check if Java SDK is installed on a Mac?
Is there a command line for this?
Make sure you correctly define the project's JDK and restart IntelliJ (full restart).
run command to see:
javac -version
Also you can verify manually by going to the specific location and then check. To do this run below command in the mac terminal
cd /Library/Java/JavaVirtualMachines/
Then run ls
command in the terminal again. Now you can see the jdk version & package if exists in your computer.
If you are on Mac OS Big Sur, then you probably have a messed up java installation. I found info on how to fix the issue with this article: https://knasmueller.net/how-to-install-java-openjdk-15-on-macos-big-sur
sudo mv openjdk-15.0.2_osx-x64_bin.tar.gz /Library/Java/JavaVirtualMachines/
cd /Library/Java/JavaVirtualMachines/
sudo tar -xzf openjdk-15.0.2_osx-x64_bin.tar.gz
sudo rm openjdk-15.0.2_osx-x64_bin.tar.gz
Note: it might be 15.0.3 or higher, depending on the date of your download.
/usr/libexec/java_home -v15
and copy the output.bash_profile
or .zshrc
file, depending on which shell you are using. You will probably have only one of these files existing in your home directory (~/.bash_profile
or ~/.zshrc
).JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home
source ~/.bash_profile
or source ~/.zshrc
java -v