Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set environment variables permanently in Mac OS 10.15.6?

I have tried all approaches I can find online, but none of them works.

I want to set JAVA_HOME and PATH environment variables permanently, so that in IntelliJ I can issue commands like "mvn".

I have written my script into .bash_profile as shown below: screenshot

But after I restarted my Mac and issued echo $JAVA_HOME, the output is still empty.

I also tried launchd.conf as said in this answer, but it didn't work either.

Could someone help me here? Thanks in advance!

like image 900
Tirion Avatar asked Oct 30 '25 10:10

Tirion


1 Answers

For osx add this in your ~/.profile or if you are using zsh inside ~/.zshrc

export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home

restart your terminal or simply apply your changes

source ~/.profile

refer this to know more about related to this question & also refer this to know more about installation process of Amazon Corretto 8.

If you are using zsh you can import .profile config inside ~/.zprofile

emulate sh
. ~/.profile
emulate zsh
like image 61
Kamal Lama Avatar answered Oct 31 '25 23:10

Kamal Lama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!