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!
More Posts related to MacOS,
- Add Line Break in Microsoft Excel Cell on Mac (macOS)
- How to view the desktop when using macOS Stage Manager?
- Mac - How to Install VirtualBox
- Must Know Homebrew Commands for Mac/Linux Users
- Show Desktop Keyboard Shortcut on Mac
- Check Reboot History Mac
- How to set Out Of Office (OOO) on Outlook for Mac
- How to Screenshot on Mac Ventura 13 - Step by Step Guide
- How to install maven in macOS using Terminal Command
- How to change macOS Safari default language
- How to hide or display Wifi icon in macOS Bug Sur Menu Bar
- Permanently Set or Change $JAVA_HOME on Mac (macOS)
- Two Ways to Extract rar (*.rar) files on Mac
- How to change Ping TTL value on macOS
- How to upgrade Docker Desktop on Mac
- [fix] macOS Ventura xcrun: error: invalid active developer path missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
- Installing brew on M1/M2 ARM Mac
- How to increase macOS Terminal text font size (Big Sur)
- How to open new tab in Sublime Text Editor [macOS]
- macOS: Change Weather App Temperature unit from Fahrenheit to Degree
- Clear SFTP Prompt Screen on macOS Terminal
- How to install homebrew (brew) on M1 Mac
- [Fix] brew: command not found Mac or Linux Terminal Error
- How to download and install macOS 13 Ventura
- How to install Zoom Add-in to Outlook (Mac)
More Posts:
- Git Remove Untracked Files using Command - Git
- Fibonacci series from 1 to 500 table - Html
- How to write hello world different languages syntax - HowTos
- How to See Hidden Folders and Files on macOS - Mac-OS-X
- Hide Bluetooth icon on Mac Menu Bar macOS Ventura 13 - MacOS
- Calculate days between dates using dateutils ddiff command - Linux
- List of 60 useful FTP Client Commands to access server - FTP
- AADSTS90033: A transient error has occurred. Please try again. [Microsoft 365] - Microsoft