Java_HOME not found when changing shell from Bash to Zsh on OSX?

This is strange, I installed JAVA_HOME for my mac, which can be found when I use the bash shell, but if I change the shell, I get a message that JAVA_HOME is not installed. What could be happening here?

+4
source share
2 answers

When you set JAVA_HOME to a shell, then it is active and available only for that context, and it will disappear when you close this shell.

Instead, change the global environment (or) of your .bashrc to include it. So that every time you start the shell, the variable will be available.

edit .profileor .bash_profileto enable JAVA_HOME.

export JAVA_HOME=`/usr/lib....`

java.

/usr/libexec/java_home -v 1.7

1.7 - , .

+3

, bash oh-my-zsh. , , zsh, bash. theres JAVA_HOME, bash, . , Unix Linux StackExchange.

zsh, .zshrc, zsh. .zshrc, . :

export JAVA_HOME=`/usr/libexec/java_home`

, ~/.zshrc:

#zshrc, interactive shell settings
export ZSH=$HOME/.zsh

# emacs integration
[[ $EMACS = t ]] && unsetopt zle

# env
if [[ -e /usr/libexec/java_home ]]; then
  export JAVA_HOME=`/usr/libexec/java_home`
fi

if [[ -e /usr/local/lib/node_modules ]]; then
  export NODE_PATH=/usr/local/lib/node_modules
fi

# path
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
export PATH=/opt/usr/sbin:/opt/sbin:/opt/usr/bin:/opt/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH=$HOME/.cabal/bin:$PATH
export PATH=$HOME/.gem/ruby/1.8/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$HOME/.bin:$PATH

setopt null_glob
# source all files in zsh root
for include in $ZSH/*.zsh; do
  source $include
done

# source all non-controlled files
for include in $ZSH/private/*.zsh; do
  source $include
done
unsetopt null_glob

source ~/.zshrc ( ), , ​​ export | grep JAVA_HOME.

mkdir ~/.zsh, , .cabal .gem, .

+11

All Articles