0

I check my last install java using this command line:

$ java -version

and output is:

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)

But in echo $JAVA_HOME:

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

How do can i set $JAVA_HOME PATH for java version 1.8?

NewCod3r
  • 1,168
  • 1
  • 12
  • 28
  • Duplicate of [What should I set JAVA_HOME to on OSX](http://stackoverflow.com/questions/1348842/what-should-i-set-java-home-to-on-osx) ? – ldz Apr 16 '17 at 12:58
  • 1
    Add export JAVA_HOME=$(/usr/libexec/java_home) to .bashrc or .zshrc file. Start bash/zsh prompt again. – dkb Apr 16 '17 at 13:13

1 Answers1

0

Not sure about Mac. But in linux which is very simliar I do something like this in my .bashrc and .bash_profile. Here you can see where I have set my JAVA_HOME. After modified those files you will have to logout and them login for the path to take affect.

# .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

And

# .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
ant2009
  • 27,094
  • 154
  • 411
  • 609