The system is DEBIAN8, Jessie, and the default Java version is: OpenJDK 1.7
1. Check the current system's Java version
leung@phychion:~$ java-version
Java Version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.2) (7u65-2.5.2-4)
OpenJDK 64-bit Server VM (build 24.65-b04, Mixed mode)
2. Configure installation Java:
leung@phychion:~/downloads$ Tar zxf jdk-7u67-linux-x64.tar.gz
leung@phychion:~/downloads$ sudo mv jdk1.7.0_67/usr/lib/jvm/
3. Edit/etc/profile, add environment variables:
leung@phychion:~/downloads$ sudo vi/etc/profile
Export java_home=/usr/lib/jvm/jdk1.7.0_67
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH
4. Use environment variables to take effect without having to log on to the shell again:
leung@phychion:~/downloads$ Source/etc/profile
5. Configure the JDK1.7 Java,javac tool:
leung@phychion:~$ sudo update-alternatives--install/usr/bin/java java/usr/lib/jvm/jdk1.7.0_67/bin/java 300
leung@phychion:~$ sudo update-alternatives--install/usr/bin/javac javac/usr/lib/jvm/jdk1.7.0_67/bin/javac 300
Update-alternatives:using/usr/lib/jvm/jdk1.7.0_67/bin/javac to Provide/usr/bin/javac (javac) in Auto mode
6. Set the default Java version of the system, here Select 2:
leung@phychion:~$ sudo update-alternatives--config java
There are 2 choices for the alternative Java (Providing/usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 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/lib/jvm/jdk1.7.0_67/bin/java Manual Mode
Press ENTER to keep the current choice[*], or type selection number:2
Update-alternatives:using/usr/lib/jvm/jdk1.7.0_67/bin/java to Provide/usr/bin/java (Java) in manual mode
leung@phychion:~$ sudo update-alternatives--config javac
There is only one alternative in link Group Javac (providing/usr/bin/javac):/usr/lib/jvm/jdk1.7.0_67/bin/javac
Nothing to configure.
7. Confirm the Java version of the settings:
leung@phychion:~$ java-version
Java Version "1.7.0_67"
Java (TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot (TM) 64-bit Server VM (build 24.65-b04, Mixed mode)