Debian (Wheezy) install Java environment/replace OpenJDK with SUN JDK

Source: Internet
Author: User

Debian (Wheezy) install Java environment/replace OpenJDK with SUN JDK

Debian (Wheezy) install Java environment/replace OpenJDK with SUN JDK

Because the project needs to install the Java environment on the machine.

1, go to the download, select the Accept License Agreement

Linux x64jdk-7u71-linux-x64.tar.gz

2, # Find a directory to put sun JDK. Here we put it in/usr/java and use numbers to indicate the version. For example, java 8 is in/usr/java/java8, java 7 is at/usr/java/java7

Create the/usr/java directory, decompress the package, and move it to/usr/java/java7.

# Mkdir/usr/java & tar-zxvf jdk-7u71-linux-x64.tar.gz & mv jdk1.7.0 _ 71/usr/java/java7

3. Write java environment variables

Open your. bashrc file. there are two, one in/root /. bashrc, one in/home/your username /. bashrc (do not write/etc/environment and do not want to affect global system environment variables)

Add the following content and save it.

Export JAVA_HOME =/usr/java/java7
Export PATH = $ PATH: $ JAVA_HOME/bin
Export CLASSPATH =.: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib


# Source/root/. bashrc switch to your user and then under source.
# Echo $ JAVA_HOME

If openjdk is not installed, enter


Now let's start the link. add to the bin of the system and use the update-alternatives command to maintain the soft connection of the system. update this command to let the system know which command to use. the last parameter is priority. higher, better.

# Update-alternatives -- install/usr/bin/java/usr/java/java7/bin/java 1100
# Update-alternatives -- install/usr/bin/javac/usr/java/java7/bin/javac 1100

Next, configure it. If you have installed openJDK, you can select it here. because I previously gave a higher priority of 1100, the default value is now under/usr/java/java7.

# Update-alternatives -- config java

# Update-alternatives -- config javac

Root @ debian:/# update-alternatives -- config java
There are 2 choices for the alternative java (providing/usr/bin/java ).

Selection Path Priority Status
0/usr/java/java7/bin/java 1100 auto mode
* 1/usr/java/java7/bin/java 1100 manual mode
2/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode

Root @ debian:/# update-alternatives -- config javac
There are 2 choices for the alternative javac (providing/usr/bin/javac ).

Selection Path Priority Status
* 0/usr/java/java7/bin/javac 1100 auto mode
1/usr/java/java7/bin/javac 1100 manual mode
2/usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 manual mode

Then, enter the terminal to verify whether Java 7 is installed.

# Java-version

Java version "1.7.0 _ 71"
Java (TM) SE Runtime Environment (build 1.7.0 _ 71-b14)
Java HotSpot (TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Install Tomcat and configure the JDK environment in CentOS

Ubuntu14.04 64-bit JDK1.7 Installation

Install JDK 7 In Ubuntu (with Clojure download)

Install JDK 12.04 in Ubuntu

CentOS6.3 install JDK and environment Configuration

This article permanently updates the link address:

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: 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.