1

I a using the latest MacOS catalina(10.15.4) and using .zshrc for my profile as latest version of mac deprecated the bash shell, This is the follow-up question of my previous unanswered question on not able to change the default java version to 1.8 using jenv.

When I was trying to debug more found my echo $JAVA_HOME always returns blank, despite having set it in following manner.

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

And

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

Note i've sourced my .zshrc file after the change but still no luck, although when I set on the terminal then it print the proper value but its only on that console(as expected).

Adding the content of my ~/.zshrc

export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
#export JAVA11_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
#export JAVA14_HOME=$(/usr/libexec/java_home -v14)
#export RUNTIME_JAVA_HOME=$(/usr/libexec/java_home -v11)
export PATH=$JAVA_HOME/bin:$PATH
#export PATH="/Users/java-dev/Library/Python/3.7/bin/:$PATH"
export PATH=/usr/local/bin:$PATH
export PATH=/usr/bin:$PATH
alias sr='source ~/.zshrc'
alias rt='cd /Users/java-dev/rt'
alias dev='cd /Users/java-dev/development'
alias code='cd /Users/java-dev/code'

1 Answers1

1

The file name is changed in latest catalina OS . you need to create a file named .zprofile (same place where you have created .bash_profile file. This needs to be done because .bash_profile is now .zprofile) and place your export command over there.

If it already exists, please append your export command in the file like below.

export PATH=$your_path$:$PATH

export JAVA_HOME=$your_path$

export M2_HOME=$your_path$

check this macOS Catalina 10.15(beta) - Why is ~/.bash_profile not sourced by my shell?

  • there is no `.bash_profile` in my home dir also as I mentioned in my question I am already using `.zshrc` and other things like aliases are working fine, moreever I tried your commands on my terminal and after `export JAVA_HOME=$your_path$` if I do `echo $JAVA_HOME` it prints just `$`, can you try these commands –  Jun 01 '20 at 09:41
  • if it is not there, can you create one under /Users/(yourHomeDIr)/ with name .zprofile and set your java_home like below export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home (in the file) – Vijay Kumar Jun 01 '20 at 09:47
  • I was facing similar issue and it got resolved once after I have created a file name .zprofile in my home dir. now java home and maven home echoes properly in any new terminal – Vijay Kumar Jun 01 '20 at 09:50
  • it didn't work , also can you provide content of your .zprofile? –  Jun 01 '20 at 10:59
  • my username in the com is vijay. file is placed under /Users/vijay/.zprofile content is export PATH=/Applications/apache-maven-3.6.3/bin/:$PATH export JAVA_HOME=/Library/Java/mypath. did u try in new terminal post this file creation? – Vijay Kumar Jun 01 '20 at 11:17