Because of the need for work, it is often necessary to switch to JDK versions like my home directory with three JDK versions:
~/apt/jdk1. 6 . 0_34 # JDK6~/apt/jdk1. 7 . 0_67 # JDK7~/apt/jdk1. 8. 0_05 # JDK8
such as compiling Android complete system source code, Google recommends the use of JDK6
In the implementation of the work, due to the actual needs of the project, to use JDK7 to implement some tools
To make it easier to switch JDK versions, I wrote a script:
1#!/bin/SH2 # Usage:. this_file [Argvs]3 4Jdk6_home=~/apt/jdk1.6. 0_345Jdk7_home=~/apt/jdk1.7. 0_676Jdk8_home=~/apt/jdk1.8. 0_057 8 # Default JDK69 Case$1 inchTen jdk6) OneExport Java_home=$jdk 6_home A ;; - jdk7) -Export Java_home=$jdk 7_home the ;; - jdk8) -Export Java_home=$jdk 8_home - ;; +* ) -Export Java_home=$jdk 6_home + ;; A Esac at -Export path= $JAVA _home/bin: $JAVA _home/jre/Bin: $PATH -Export classpath= $CLASSPATH: $JAVA _home/lib: $JAVA _home/jre/lib
How to use:
For example, execute in the shell when you need to switch the JDK7 . [Script file name] Jdk7
Premise: Download and extract JDK7 to ~/apt/jdk1.7.0_67(modify according to your own needs)
JDK version download Link:
Java SE 1.1:http://www.oracle.com/technetwork/java/javasebusiness/downloads/ java-archive-downloads-javase11-419415.html
Java SE 1.2:http://www.oracle.com/technetwork/java/javasebusiness /downloads/java-archive-downloads-javase12-419414.html
Java SE 1.3:http://www.oracle.com/technetwork/java/ Javasebusiness/downloads/java-archive-downloads-javase13-419413.html
Java SE 1.4:http://www.oracle.com/ technetwork/java/javasebusiness/downloads/java-archive-downloads-javase14-419411.html
JDK5 Download:/http Www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html
JDK6 Download: http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
JDK7 Download: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
JDK8 Download:/http www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html