Because Ubuntu will bring OPEN-JDK preinstalled in the system, when we need to install the JDK under Ubuntu, we found that even after the environment variables are configured, the input java-version version still does not change, we need the following 2 steps to switch/usr/local /java points to the JDK
##############################################
#第一步 We need to update the new version of the Java command to the system/usr/bin/301 is the priority
##############################################
sudo update-alternatives--install/usr/bin/java java/usr/local/jdk1.8.0_45/jre/bin/java 301
##############################################
#第二步 We reconfigure Java to select your newly installed JDK, after completing the java-version to see if the success
##############################################
[Email protected]:/usr/local$ sudo update-alternatives--config java
There are 2 candidates that can be used to replace Java (providing/usr/bin/java).
What we want.
Select Path Priority State
------------------------------------------------------------
0/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Auto mode
* 1/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Manual mode
2/usr/local/jdk1.8.0_45/jre/bin/java 301 Manual Mode
to maintain the current value [*] press ENTER, or type the number of your choice: 2
Update-alternatives:using/usr/local/jdk1.8.0_45/jre/bin/java to Provide/usr/bin/java (Java) in manual mode
[Email protected]:/usr/local$ java-version
Picked up _java_options:-dawt.usesystemaafontsettings=gasp
Java Version "1.8.0_45"
Java (TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot (TM) 64-bit Server VM (build 25.45-b02, Mixed mode)
Switch JDK version under Ubuntu