Install the JDK in Ubuntu 14.04 to install jdk6,7 or 8.

Source: Internet
Author: User
http://blog.csdn.net/yuxiayiji/article/details/37812785
There are also a number of ways to install the JDK on a Linux system.

The simplest should be in the Software Center search, direct download installation, this process is automatic, can also download the installation package on the Internet, decompression installation itself, there is a way to download and install in the terminal. Here the main record of the terminal download installation steps.

Install the JDK in Ubuntu 14.04 to install jdk6,7 or 8.



Step one: Add the PPA repository to the system

tzhuwb@ubuntu:/$ sudo add-apt-repository Ppa:webupd8team/java



Step Two: Update

tzhuwb@ubuntu:/$ sudo apt-get update



Step three: Download and install the JDK

tzhuwb@ubuntu:/$ sudo apt-get install Oracle-java7-installer

Installed here is JDK7, if you want to install JDK6 or JDK8, the above statement to the corresponding number of 7.



Step Fourth: Set to Default

tzhuwb@ubuntu:/$ sudo apt-get install Oracle-java7-set-default

Similarly, it is necessary to change the 7 to the corresponding 6 or 8.

Fifth Step: View version

tzhuwb@ubuntu:/$ java-version
Java Version "1.7.0_55"
Java (TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot (TM) Client VM (build 24.55-b03, Mixed mode)

To modify a configuration file:

Gedit/etc/profile at the end of the file add:


#jdk

Export Java_home=/usr/lib/jvm/java-7-oracle
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH


. Just one JDK does not have to set the default, if there are other versions of the need to set the default version of the

Step Fourth: Configure the default JDK version
To set the JDK that we have installed as the default JDK version, the following work is done.
Execute code:

sudo update-alternatives--install/usr/bin/java Java/usr/lib/jvm/java-7-oracle/bin/java 300

Execute code:

sudo update-alternatives--config java

The system lists the various JDK versions, as follows:

www.linuxidc.com@linux:~$ sudo update-alternatives--config java
There are 3 candidates that can be used to replace Java (provide/usr/bin/java).


Select 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/java-7-sun/bin/java 300 Manual Mode


To maintain the current value [*] press ENTER or type the selected number: 3
Update-alternatives: Use/usr/lib/jvm/java-7-sun/bin/java to provide/usr/bin/java (Java) in manual mode.

Step Fifth: Test

Java-version (Displays the following information stating that the configuration was successful)
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)

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.