CentOS installation JDK 1.6 tutorial

Time:2021-5-10

In Linux, many programs need JDK support, but JDK 1.7 is too new for these programs. I will install JDK 1.6 today
 
System: CentOS 5.5 (32-bit)
Required software package: jdk-6u32-linux-i586-rpm.bin

1. Download JDK
Download JDK 1.6 from the official website
Address: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html

2. Install JDK 1.6

Copy code

The code is as follows:

chmod +x jdk-6u32-linux-i586-rpm.bin
./jdk-6u32-linux-i586-rpm.bin

3. Switch from openjdk to sun JDK

Copy code

The code is as follows:

alternatives –install /usr/bin/java java /usr/java/default/bin/java 1
alternatives –install /usr/bin/javac javac /usr/java/default/bin/javac 1

4. Select the required version

Copy code

The code is as follows:

alternatives –config java

5. Set system environment variables

Copy code

The code is as follows:

vi /etc/profile</p>
<p>export JAVA_HOME=/usr/java/default
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

To execute an order to make it effective:

Copy code

The code is as follows:

source /etc/profile

6. View java version:

Copy code

The code is as follows:

java -version