1, in http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html download the latest version of the rpm file, Mine is the first one in the x86 system.
Download and drag to the Linux virtual machine.
2, running RPM-IVH jdk-8u25-linux-i586.rpm installation after installation should be installed in the/USR/JAVA/JDK1.8.0_25
3, set the environment variable run vim/etc/profile at the end of the file input
Export java_home=/usr/java/jdk1.8.0_25
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin
4, confirm the version input java-version look at the current version, if you do not install it, you need to choose your own newly installed version as the default
5. Change the default version
5.1 Add the new JDK to the ready-to-use option first
Input sudo update-alternatives--install/usr/bin/java java /usr/java/jdk1.8.0_25/bin/java 300// Note that the underlined part is the address of the JDK we just installed.
Input sudo update-alternatives--install/usr/bin/javac javac /usr/java/jdk1.8.0_25/bin/javac 300
5.2 Changing the default version
Enter sudo update-alternatives--config java there will be some alternatives, select the version you just added to
Finally, enter the java-version to see if the success is as shown.
"Linux" JDK installation