You make have noticed that if you use the export command JAVA_HOME = your/java/home/path on the console, it will only be active for the particular session. In order to permanently set $JAVA_HOME, you need to see it in the shell profile file, for Mac running on macOS it should be the .zshrc file,
Steps to Permanently Set $JAVA_HOME on Mac
- Open Terminal,
- Type: nano ~/.zshrc (or vi ~/.zshrc if you are a Vi guy!)
- Now add your JAVA_HOME=/your/java/jdk/home/path, somewhere in the file, if its empty add it at the start (then mostly you just created it :)) if it's not empty, it is good to add as the last line.
- Save the file (Control + X followed by Y, if using Nano Editor)
- Now just type zsh to refresh the shell or source ~/.zshrc to reflect the change permanently!

Have Questions? Post them here!
- How to find path of file on Mac Terminal
- How to disable Siri on Mac Monterey
- [fix] macOS Ventura xcrun: error: invalid active developer path missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
- Select Line Number TextEdit on Mac
- Go to Specific file path using Mac Finder
- How to find Java HOME in Mac Terminal
- bash: command not found error [macOS Terminal Linux, Unix or Windows]
- Must Know Homebrew Commands for Mac/Linux Users
- How to Insert an Inverted Question Mark on Mac ¿
- Hide Keyboard Text Input Icon on macOS Ventura Menu Bar
- How to make macOS Terminal window Transparent (or Opaque)
- How to check of Updates on Microsoft Edge Browser on Mac (macOS)
- Limit scrollback rows in macOS Terminal
- How to identify installed Java (JDK) Version on macOS
- Keyboard Shortcut to delete a file on a Mac [Macbook]
- Open Docker from Terminal Command on Mac
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to take a screenshot on a Mac - updated for Ventura 13 [updated 2023]
- ls: .: Operation not permitted - Mac Terminal ZSH Error
- How to remove username from Mac Menu Bar?
- macOS Ventura XCode Command Line Tools Installation
- Where is .zshrc file located in macOS
- How to Show Path of Files or App in Mac Spotlight Search
- How to enable root user on Mac Terminal
- Install Java 17 (LTS) JDK on ARM based M1/M2 Mac Natively
- Microsoft Teams Error - You cannot add another work account to Teams at the moment - Teams
- How to make jsfiddle bootstrap ready - CSS
- Eclipse like Auto Import Shortcut in Intelij IDE Android Studio - Android-Studio
- What is the Max and Minimum Value of int type in Python? - Python
- [Fix] Ubuntu E: Unable to locate package sudo error - Ubuntu
- Duplicate id @+id/textView1, already defined earlier in this layout Android Error - Android
- Java XML-RPC 3.1.x based web service example - Java
- Align left align text in Bootstrap - Bootstrap