Download the latest java from Oracle https://www.oracle.com/java/technologies/downloads/#jdk19-mac
- Open terminal and check the java version
java --version
java 19 2022-09-20
Java(TM) SE Runtime Environment (build 19+36-2238)
Java HotSpot(TM) 64-Bit Server VM (build 19+36-2238, mixed mode, sharing)
2. Check if JAVA_HOME is set echo $JAVA_HOME
3. If it returned empty then on the home / check for the file ~/.zshenv by hitting ls -al
4. If the file already exist open it if not found create using touch ~/.zshenv
5. Open the file using open ~/.zshenv
6. on the terminal hit /usr/libexec/java_home
7. It’ll return the Java installation path as /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
8. Copy and past in the file .zshenv as export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
9. Save Cmd+S and close the file
10. Make sure the file saved by hitting cat ~/.zshenv to see what’s in the file
11. Close the terminal and reopen
12. Hit echo $JAVA_HOME it should return the java path
[…] Make sure you already installed JAVA 11 and setup JAVA_HOME and also installed Maven and setup MAVEN_HOME environment […]
[…] Make sure you install Java 11 or a later version and set up JAVA_HOME. (Both JRE or JDK required.) […]