Configure JDK 7 in Ubuntu12.04

Source: Internet
Author: User
Step 1: Download jdkhttp: // response

Step 1: Download jdk
Http://www.oracle.com/technetwork/java/javase/downloads/index.html

Step 2: unzip and install
Go to the directory where the file is located and execute sudo tar zxvf jdk-7-linux-i586.tar.gz-C/usr/lib/jvm
Decompress the package to/usr/lib/jvm.

Step 3: Modify Environment Variables
Sudo gedit/etc/environment

PATH = "......:/usr/lib/jvm/java/jdk1.6.0 _ 12/bin"
CLASSPATH =.:/usr/lib/jvm/java/jdk1.6.0 _ 12/lib
JAVA_HOME =/usr/lib/jvm/java/jdk1.6.0 _ 12

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

Source ~ /. Bashrc

Step 4: configure the default JDK version
Ubuntu may have a default JDK, such as openjdk. To set the installed JDK to the default JDK version, perform the following operations:

Sudo update-alternatives -- install/usr/bin/java/usr/lib/jvm/jdk7/bin/java 300
Sudo update-alternatives -- install/usr/bin/javac/usr/lib/jvm/jdk7/bin/javac 300
Sudo update-alternatives -- install/usr/bin/jar/usr/lib/jvm/jdk7/bin/jar 300

Run

Sudo update-alternatives -- config java

JDK versions are listed as follows:

Three candidate items can be used to replace java (/usr/bin/java ).


Select the path priority status
------------------------------------------------------------
* 0/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 automatic mode
1/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2/usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3/usr/lib/jvm/jdk7/bin/java 300 manual mode


To maintain the current value [*], press the Enter key or enter the selected number: 3
Update-alternatives:/usr/lib/jvm/jdk7/bin/java is used to provide/usr/bin/java (java) in manual mode.

Step 5: Test
If java-version is executed and the corresponding version information is displayed, the configuration is successful.

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

Related Article

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.