Install and configure JDK 7 in Linux

Source: Internet
Author: User

Since the acquisition of Sun from Oracle for nearly three years, there have been many changes. As early as August, Oracle terminated the "Operating System Distributor License for Java" License, meaning that third parties will not be able to distribute their software packages based on this License.

Therefore, Ubuntu Linux has started to disable the Oracle JDK browser plug-in on all machines and will soon Delete the software package from the file.

The company pointed out that disabling Oracle plug-ins can help improve security, because these plug-ins have been confirmed to contain many vulnerabilities, although this is a fact, but the real reason is probably that Sun's JDK will clear software that is considered unsafe on the user's machine during upgrade. Most PC users think this is safe, however, users based on UNIX systems do not think so.

After the JDK of Oracle is deprecated, OpenJDK will be installed on Ubuntu and other Linux systems by default.

Although many Linux distributions now come with OpenJDK, it is slightly different from Oracle-JDK (SUN-JDK) in the development process. Generally, Java developers use Oracle-JDK as the standard for development.

The following describes how to install and configure JDK in Linux. the Linux release version is Ubuntu 12.04.

1. Download JDK

The latest JDK version is Java SE Development Kit 7u5.

: Http://download.oracle.com/otn-pub/java/jdk/7u5-b06/jdk-7u5-linux-i586.tar.gz

View latest: http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. Unzip and install

Install JDK to this path:/usr/lib/jvm

If this directory does not exist (of course not exist for the first time), we will create a new directory.

Cd/usr/lib

Sudo mkdir jvm

After the creation, we will go to the directory of the downloaded compressed package, decompress it to the folder we just created, and modify the name to facilitate our management.

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

Cd/usr/lib/jvm

Sudo mv jdk1.7.0 _ 05/jdk7

3. Configure Environment Variables

Gedit ~ /. Bashrc

Add

Export JAVA_HOME =/usr/lib/jvm/jdk7

Export JRE_HOME =$ {JAVA_HOME}/jre

Export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib

Export PATH =$ {JAVA_HOME}/bin: $ PATH

Save and exit, and then enter the following command to make it take effect

Source ~ /. Bashrc

4. Configure the default JDK

The default JDK exists in some Linux distributions, such as OpenJDK. So in order to make the installed JDK version become the default JDK version, we need to make the following configuration.

Run the following command:

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

Note: If the above two commands fail to find the path, restart the computer and repeat the above two lines of code.

Run the following code to view the current JDK versions and configurations:

Sudo update-alternatives -- config java

5. Test

Open a terminal and enter the following command:

Java-version

Display result:

Java version "1.7.0 _ 05"

Java (TM) SE Runtime Environment (build 1.7.0 _ 05-b05)

Java HotSpot (TM) Server VM (build 23.1-b03, mixed mode)

This indicates that the java command can be run.

Install JDK 7 In Ubuntu (with Clojure download)

Install JDK and Eclipse for C/C ++ in Ubuntu 13.10 (solving global menu problems)

Linux VPS configuration to build a Java server environment (JDK + Tomcat + MySQL)

Install JDK in RedHat

CentOS installation and configuration JDK and Tomcat support jsp File Parsing

Install sun JDK7 on Ubuntu 12.04 LTS

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.