Skip to content

Instantly share code, notes, and snippets.

@berngp
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berngp/9985410 to your computer and use it in GitHub Desktop.
Save berngp/9985410 to your computer and use it in GitHub Desktop.
Dealing with Java 8 and 7 in the same Environment.
# snippet from my ~/.zshrc file.
export JAVA7_HOME="$(/usr/libexec/java_home -v 1.7)"
function with-jdk7
{
export JAVA_HOME="$JAVA7_HOME"
echo "$@"
$@
}
export JAVA8_HOME="$(/usr/libexec/java_home -v 1.8)"
function with-jdk8
{
export JAVA_HOME="$JAVA8_HOME"
echo "$@"
$@
}
# now you can do..
# $ width-jdk7 scala
# $ width-jdk7 spark-shell
@cfieber
Copy link

cfieber commented Apr 5, 2014

export JAVA7_HOME=/usr/libexec/java_home -v 1.7

@berngp
Copy link
Author

berngp commented Aug 13, 2014

@cfieber why am I just reading your comment... I was not aware of that trick! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment