11

I am using Jenv to manage multiple java version on My MacBook(OS X Yosemite).

jenv add /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
oracle64-1.6.0.65 added
1.6.0.65 added
1.6 added

and while adding Java 1.8

jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
oracle64-1.8.0.60 added
1.8.0.60 added
1.8 added

and jenv version show multiple line of the same version infact it is one version?

jenv versions

    * system (set by /Users/$USERNAME/.jenv/version)
      1.6
      1.6.0.65
      1.8
      1.8.0.60
      oracle64-1.6.0.65
      oracle64-1.8.0.60
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
Sasi Kathimanda
  • 1,788
  • 3
  • 25
  • 47

3 Answers3

2

If you look inside the .jenv folder you can see all the three different instances of the same version.

Vishwaksena
  • 392
  • 5
  • 16
  • yes but why? eg: for one version why it repeated say 1.6 , 1.6.065, oracle64-1.6.0.65 – Sasi Kathimanda Nov 11 '15 at 18:00
  • 1.6 is the major version and the others are the minor versions. If you have any bugs related to major version and want to use a specific fixed version you can switch to 1.6.0.XX or to use a version from a specific oracle version or any other. – Vishwaksena Nov 12 '15 at 14:47
2

You can always add/remove/change aliases in your ~/.jenv/versions folder. Those are just links.

Andrey Lebedenko
  • 1,850
  • 17
  • 24
  • Thanks, I had a repository that wanted me to use `17` but `jenv` had only added symlinks for `17.0` and `17.0.4` so I was quickly able to add another one manually for `17`. – Dawngerpony Mar 16 '23 at 11:26
1

I wrote a script to handle my JEnv environment.

# configure Java  http://www.jenv.be/
# install Java: brew cask install java, brew cask install java7
# set global default: setJavaGlobal 1.7, jenv global 1.7
# set local folder default: jenv local 1.8
# 
JENV_HOME=$HOME/.jenv
export PATH=.:$PATH:$JENV_HOME/bin
eval "$(jenv init -)"
#export JAVA_HOME=$(/usr/libexec/java_home)
export JAVA_HOME="$HOME/.jenv/versions/`jenv version-name`"
alias jenv_set_java_home='export JAVA_HOME="$HOME/.jenv/versions/`jenv version-name`"'
setJavaGlobal() { 
  jenv global $1;
  jenv_set_java_home
  echoJavaSetup
}
setJavaLocal() { 
  jenv local $1;
  jenv_set_java_home
  echoJavaSetup
}
echoJavaSetup() {
  echo --------------------
  echo NEW JAVA SETUP:
  echo "  PATH: $PATH"
  export JAVA_VERSION=`java -version 2>&1 >/dev/null | grep 'java version' | awk '{print $3}'`
  echo "  JAVA: $JAVA_VERSION, $JAVA_HOME"
  jenv versions
  echo --------------------
}
removeJavaLocal() {
  rm -rf ./.java-version
}
showJava() {
  echo --------------------
  echo EXISTING JAVA SETUP:
  echo "  PATH: $PATH"
  export JAVA_VERSION=`java -version 2>&1 >/dev/null | grep 'java version' | awk '{print $3}'`
  echo "  JAVA: $JAVA_VERSION, $JAVA_HOME"
  jenv versions
  if [ -f ./.java-version ]; then
    echo "Using Java LOCAL DEFAULT.  Not using global default!  Run command 'removeJavaLocal' to change to global default."
  fi
  echo --------------------
}
djangofan
  • 28,471
  • 61
  • 196
  • 289