Install and configure JDK 7 in Ubuntu

Source: Internet
Author: User
Step 1: Download jdk-7-linux-i586.tar.gz [Plain]
View plaincopy
  1. Http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz wget-C

(Note: If the download fails, we recommend that you use thunder to download it and copy it to the Linux system .)

Step 2: unzip and install [Plain]
View plaincopy
  1. Sudo tar zxvf./jdk-7-linux-i586.tar.gz-C/usr/lib/JVM
  2. CD/usr/lib/JVM
  3. Sudo MV jdk1.7.0/Java-7-sun
Step 3: Modify Environment Variables [Plain]
View plaincopy
  1. Vim ~ /. Bashrc

Add:[Plain]
View plaincopy

  1. Export java_home =/usr/lib/JVM/Java-7-sun
  2. Export jre_home =$ {java_home}/JRE
  3. Export classpath =. :$ {java_home}/lib :$ {jre_home}/lib
  4. Export path =$ {java_home}/bin: $ path

Save and exit. Enter the following command to make it take effect immediately.

[Plain]
View plaincopy
  1. Source ~ /. Bashrc
Step 4: configure the default JDK version

Ubuntu may have a default JDK, such as openjdk. To set the JDK we installed as the default JDK version, perform the following work.
Run the Code:[Plain]
View plaincopy

  1. Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/JVM/Java-7-sun/bin/Java 300
  2. Sudo Update-alternatives -- install/usr/bin/javac/usr/lib/JVM/Java-7-sun/bin/javac 300
  3. Sudo Update-alternatives -- install/usr/bin/Jar/usr/lib/JVM/Java-7-sun/bin/jar 300

Run the Code:[Plain]
View plaincopy

  1. Sudo Update-alternatives -- config Java

JDK versions are listed as follows:[Plain]
View plaincopy

  1. Snowdream @ snowdream :~ $ Sudo Update-alternatives -- config Java
  2. Three candidate items can be used to replace Java (/usr/bin/Java ).
  3. Select the path priority status
  4. ------------------------------------------------------------
  5. * 0/usr/lib/JVM/java-6-openjdk/JRE/bin/Java 1061 automatic mode
  6. 1/usr/lib/JVM/java-6-openjdk/JRE/bin/Java 1061 manual mode
  7. 2/usr/lib/JVM/Java-6-sun/JRE/bin/Java 63 manual mode
  8. 3/usr/lib/JVM/Java-7-sun/bin/Java 300 manual mode
  9. To maintain the current value [*], press the Enter key or enter the selected number: 3
  10. Update-Alternatives:/usr/lib/JVM/Java-7-sun/bin/Java is used to provide/usr/bin/Java (Java) in manual mode.
Step 5: Test [Plain]
View plaincopy
  1. Snowdream @ snowdream :~ $ Java-version
  2. Java version "1.7.0"
  3. Java (TM) se Runtime Environment (build 1.7.0-b147)
  4. Java hotspot (TM) server VM (build 21.0-b17, mixed mode)

Reference link:
1. Install JDK configuration eclipse and tomcat under Ubuntu 10.10 [reprint + correction] http://www.cnblogs.com/evasnowind/archive/2011/01/05/1926059.html
2, ubuntu jdk installation process (for reference only) http://forum.ubuntu.org.cn/viewtopic.php? T = 183803
3, Java learning JDK installation http://www.cnblogs.com/shaoguobao/archive/2011/07/16/2108015.html

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.