How to install JDK 12.10 In Ubuntu

Source: Internet
Author: User

JDK (JavaDevelopment Kit) is the core of Java, including the Java Runtime Environment, tools, and basic class libraries. JDK has multiple versions. The common version is Java SE, which is the standard version. This article is the installation method of the standard version 7bs. The installation steps for Ubuntu 12.10 are as follows.

1. Download the Installation File

On the JDK official website www.Oracle.com, go to the download page, Select accept authorization protocol, and then select the corresponding file to download. In this installation practice, select the jdk-7u17-linux-i586.tar.gz for linuxx86. as for the installation of jdk-7u17-linux-i586.rpm, refer to other documents.

For the download method, you can use commands or manually download them.

2. decompress the package to the target folder.

Skip this step if the target folder exists. Otherwise, enter the following command to create the target Folder:

Sudo mkdir/usr/lib/jvm

Enter the following command to decompress jdk-7u17-linux-i586.tar.gz to the target Folder:

Sudo tar zxvf./jdk-7u17-linux-i586.tar.gz-C/usr/lib/jvm

In this installation practice, jdk-7u17-linux-i586.tar.gz in the root directory of the current user, the second parameter of the tar command is./jdk-7u17-linux-i586.tar.gz, of course, you can use the absolute path, no more details.

3. Add Environment Variables

Run the following command to open the file:

Gedit ~ /. Bashrc

The following statement is used at the end of the. bashrc file:

# Java jdk configuration
Export JAVA_HOME =/usr/lib/jvm/jdk1.7.0 _ 17
Export JRE_HOME =$ {JAVA_HOME}/jre
Export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
Export PATH =$ {JAVA_HOME}/bin: $ PATH

Run the following command to make it take effect immediately:

Source ~ /. Bashrc

In this article, the environment variables are modified in ~ /. Bashrc only applies to the current user. If/etc/profile is modified, it applies to all users.

4. Test JDK

Run the following command to view the JDK version:

Java-version

If the installation is successful, the following content is displayed:

Java version "1.7.0 _ 17"
Java (TM) SE Runtime Environment (build 1.7.0 _ 17-b02)
Java HotSpot (TM) Server VM (build 23.7-b01, mixed mode)

5. Configure the default JDK version.

If there is only one JDK in the system, the above steps have been completed. If multiple jdks exist in the system, such as openjdk and sunjdk, You need to configure the default JDK by following the steps below.

1) execute the following command:

Sudo update-alternatives -- install/usr/lib/java/usr/lib/jvm/jdk1.7.0 _ 17/bin/java 300
Sudo update-alternatives -- install/usr/lib/javac/usr/lib/jvm/jdk1.7.0 _ 17/bin/javac 300

2) execute the following command:

Sudo update-alternatives -- config java

In this case, the system lists information about JDK versions. The default JDK is marked. To maintain the current default JDK, press the Enter key. Otherwise, enter the corresponding JDK number and set it to the default version.

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.