Different projects use different versions of Java, each time you need to manually modify the Java environment variables, it is extremely troublesome.
Jenv can manage Java versions and easily manage multiple Java issues.
First, download jenv
$ git clone https://github.com/gcuisinier/jenv.git ~/.jenv
Second, the environment variables to be included
Echo ' export path= "$HOME/.jenv/bin: $PATH" ' >> ~/.bash_profile
Third, execute the JENV init-command, so that each bash terminal can be opened to invoke the Jenv command, and the default execution of the JENV init-command.
Echo ' eval "$ (jenv init-)" ' >> ~/.bash_profile
Iv. viewing the current Java version, the output is 1.8.0_44
$ java-version
V. Locate the folder path for jdk1.8 and jdk1.7, and add to the JENV Management library:
$ jenv add/opt/java/jdk1. 8 /opt/java/jdk1. 7. 0_80
Vi. viewing Java versions that have been added
$ jenv Versions
Seven, configure the JVM to be used. There are three ways: global: By Overall, lacal: by directory, Shell:shell
$ jenv Global jdk1.7.0_80
Or
$ jenv Local jdk1.7.0_80
Or
$ jenv Shell jdk1.7.0_80
Eight, view the current Java version. The discovery version has become jdk1.7.0_80.
$ java-version
At this point, no longer have to manually modify the environment variables to change the Java version.
Linux Java Version Management tool JENV usage Introduction