General method (recommended)
Skip the first five steps when there is no network but JDK. Bin.
1. CD/usr
2. Create a Java installation directory under the USR directory
Sudo mkdir Java
3. Copy jdk-6u24-linux-i586.bin to the Java directory
Sudo CP/directory/jdk-6u24-linux-i586.bin/usr/Java
4. Install JDK
Sudo./jdk-6u24-linux-i586.bin
5. After the installation is complete, create a link for him to save the directory Length
Sudo ln-S/usr/Java/jdk1.6.0 _ 24 // usr/JDK
The preceding steps are not required when there is a network.
Sudo apt-Get install sun-java6-jdk directly
Then you need to set the default Java program
Sudo Update-alternatives -- config Java
Enter the corresponding options as prompted, and set them to JDK 6.
The following settings
Sudo Vim/etc/environment
Add the following two lines:
Classpath =/usr/lib/JVM/Java-6-sun/lib
Java_home =/usr/lib/JVM/Java-6-sun
If classpath and java_home are already set, change them to the above format and press ZZ to save and exit.
6. Edit the configuration file
Sudo Vim/etc/profile
Add the following content:
Java_home =/usr/JDK
Classpath = $ java_home/lib/
Path = $ path: $ java_home/bin
Export path java_home classpath
8. Restart the machine
Sudo shutdown-R now
9. view the installation status
Java-version
java version "1.6.0_24"Java(TM) SE Runtime Environment (build 1.6.0_24-b07)Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)
Lazy Method
1. Download jdk7 from the official website and install it to usr/lib/JVM. You can create a sudo mkdir JVM without a JVM folder.
2. Configure JDK
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
3. Test
Because only this JDK is available, no configuration is required.
java -versionjavac -version
The published document number is displayed successfully.
The reference documents are as follows:
Install the JDK
JDK 7 package is extracted into./jdk1.7.0 _ 02 directory.-Now move the JDK 7 directory/usr/lib
sudo mv ./jdk1.7.0_02 /usr/lib/jvm/jdk1.7.0
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
sudo update-alternatives --config java
You will see output similar one below-choose the number of jdk1.7.0-for example3In this list:
$sudo update-alternatives –config javaThere are 3 choices for the alternative java (providing /usr/bin/java).Selection Path Priority Status————————————————————* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual modePress enter to keep the current choice[*], or type selection number: 3update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.
Check the version of you new JDK 7 installation:
java -version
java version “1.7.0”Java(TM) SE Runtime Environment (build 1.7.0-b147)Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)
Repeat the above:
sudo update-alternatives --config javacsudo update-alternatives --config javaws
Enable Mozilla Firefox Plugin:
32 bit:ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/64 bit:ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/