3

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!

Tirion
  • 117
  • 1
  • 2
  • 11

2 Answers2

3

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
Kamal Lama
  • 690
  • 2
  • 5
  • 20
  • @Tirion I have updated the answer. Would you, please, try that and let me know if it works for you. – Kamal Lama Aug 28 '20 at 02:58
  • Sorry it still doesn't work. The problem is not what is the content of the `.profile` file, it is the file doesn't write anything into env variable at all. Thanks for your reply anyway. – Tirion Aug 28 '20 at 13:07
1

Check your enviroment variables with

env 

then check if your config files are in the right directory. Read /etc/profile e.g.

nano /etc/profile

There can you find the path to bashrc file

Luis Galaz
  • 390
  • 4
  • 9