为Java 1.8 OSX sierra设置JAVA_HOME PATH不起作用

时间:2017-04-16 12:53:54

标签: java macos path macos-sierra

我使用此命令行检查我的上次安装java:

$ java -version

,输出为:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

但在echo $JAVA_HOME

/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

如何为java版$JAVA_HOME设置1.8 PATH?

1 个答案:

答案 0 :(得分:0)

不确定Mac。但是在我非常简单的linux中,我在.bashrc.bash_profile中执行了类似的操作。在这里你可以看到我在哪里设置了我的JAVA_HOME。修改完这些文件后,您必须注销,然后登录才能生效。

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
export JAVA_HOME=/home/steve/.local/share/android-studio/jre
export GRADLE_HOME=/opt/gradle/gradle/bin
export ADB=/home/steve/Android/Sdk/platform-tools
export ANDROID_HOME=/home/steve/Android/Sdk

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin:$JAVA_HOME/bin:$ADB:$ANDROID_HOME

export PATH