Execute command: sudo update-alternatives--config java
There is 2 choices for the alternative Java (Providing/usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 Auto Mode
1/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Manual Mode
2/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 Manual Mode
Select 1
Then the server's global variable Java is turned into
Java-version
Java Version "1.7.0_121"
OpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1ubuntu0.14.04.3)
OpenJDK 64-bit Server VM (build 24.121-b00, Mixed mode)
If you only want to replace the Java environment for individual users, follow these steps:
CD ~
Vim. Profile (Join the following Java path)
Export JAVA_HOME=/USR/LIB/JVM/JAVA-8-OPENJDK-AMD64 is mainly to see where the root directory of JAVA, and then add in user profile inside the good
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Wq Save exit
Souce. Profile
Ubuntu Switch Java Environment, configure a separate user environment