Install JDK in Linux

Source: Internet
Author: User

Step 1: Download JDK

Go to Oracle official website to download jdk-6u45-linux-i586.bin

Http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html

Step 2. Unzip and install

Chmod 755 jdk-6u43-linux-i586.bin
./Jdk-6u43-linux-i586.bin
(Note that this step must be in the jdk-6u11-linux-i586.bin directory) Self-extract

Put the extracted files in the directory you want to install (I am/usr/lib/JVM/Java and put jdk1.6.0 _ 45)

Step 3: Modify Environment Variables

Gedit/etc/environment

Modify (ADD ):

[Java]
View plaincopyprint?
  1. Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/Games"
  2. Java_home =/usr/lib/JVM/Java/jdk1.6.0 _ 45
  3. Jre_home =$ {java_home}/JRE
  4. Classpath =. :$ {java_home}/lib: $ {jre_home}/lib
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0_43JRE_HOME=${JAVA_HOME}/jre  CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  

Then reload. bashrc

[Java]
View plaincopyprint?
  1. Source ~ /. Bashrc
 source ~/.bashrc  

Step 4: Modify the default configuration items

[Java]
View plaincopyprint?
  1. Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/JVM/Java/jdk1.6.0 _ 45/bin/Java 300
  2. Sudo Update-alternatives -- install/usr/bin/javac/usr/lib/JVM/Java/jdk1.6.0 _ 45/bin/javac 300
  3. Sudo Update-alternatives -- install/usr/bin/Jar/usr/lib/JVM/Java/jdk1.6.0 _ 45/bin/jar 300
  4. Sudo Update-alternatives -- install/usr/bin/javah/usr/lib/JVM/Java/jdk1.6.0 _ 45/bin/javah 300
  5. Sudo Update-alternatives -- install/usr/bin/javap/usr/lib/JVM/Java/jdk1.6.0 _ 45/bin/javap 300
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/jdk1.6.0_43/bin/java 300sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/jdk1.6.0_43/bin/javac 300sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/java/jdk1.6.0_43/bin/jar 300sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java/jdk1.6.0_43/bin/javah 300sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/java/jdk1.6.0_43/bin/javap 300

-- If this parameter is not added, openjava is used to detect it in Java-version.

Sudo Update-alternatives -- config Java

Step 5: Test

[Java]
View plaincopyprint?
  1. Without @ without-PC :~ /Downloads $ Java-version
  2. Java version "1.6.0 _ 45"
  3. Java (TM) se Runtime Environment (build 1.6.0 _ 45-b01)
  4. Java hotspot (TM) server VM (build between 14-b01, mixed mode)

Http://blog.csdn.net/without0815/article/details/8686755

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.