Installation and configuration of JDK environment under ubuntu-12.04.1-desktop-x64

Source: Internet
Author: User

1. Download the latest JDK on Oracle's website.
Here, my system is UBUNTU-12.04.1-DESKTOP-AMD64, the latest version of the current location JDK bit 7u9.
Jdk-for-linux has two kinds of installation packages, one is RPM and the other is. tar.gz.
Here I have chosen jdk-7u9-linux-x64.tar.gz.

(I also tried to download the version of jdk-7u9-linux-x64.rpm for installation, but there was a "dependency detection failure" error and various files were required.) Although some parameters can be used to ignore dependency detection to force the installation, but faint feeling of the appearance of inappropriate, so there is no attempt.
Then try using alien to convert the RPM package into a deb package, install it with dpkg, but still be wrong (still seems to be missing something). )
All kinds of help without fruit, but can only use the official website provided. tar.gz to install the configuration. The problem with RPM is to expect the great God to solve it. )

2. Unzip the downloaded tar package.
Ctrl+alt+t Open the terminal.
Use the CD command to navigate to the directory where the downloaded jdk-7u9-linux-x64.tar.gz is located
sudo tar-zxvf jdk-7u9-linux-x64.tar.gz-c/usr/lib dir

3. Setting Environment variables
Method One:
sudo gedit/etc/profile
Add the following code at the end of the file:
Export java_home=/usr/lib/jdk1.7.0_09
Export JRE_HOME=/USR/LIB/JDK1.7.0_09/JRE
Export path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin
Exportclasspath= $CLASSPATH:.: $JAVA _home/lib: $JAVA _home/jre/lib

Export a defined variable in a high-level language.
$ variable name stands for reference variable
: As a delimiter, the equivalent of the + in string operations in Java
= is an assignment character.

Method Two:
sudo vi/etc/environment
Add the following address inside the double quotation mark following path:
$JAVA _home/bin: $JAVA _home/jre/bin
Add the following variables:
Java_home= "/usr/lib/jdk1.7.0_09"
Jre_home= "/usr/lib/jdk1.7.0_09/jre"
Path= "$JAVA _home/bin: $JAVA _home/jre/bin"
Classpath= ".: $JAVA _home/lib: $JAVA _home/jre/lib"
And then execute
Source/home/prpl/.bashrc
Note: PRPL changes to the user name that corresponds to your system.


Method one sets the user environment, and the second method is to set the environment variables of the whole system. Each has its merits and demerits. For details, please go to this link to see:
"Ubuntu system/etc/profile and/etc/environment comparison"

--a blog not reflected by Mu Fu

4. Modify the system default JDK
sudo update-alternatives--install/usr/bin/java Java/usr/lib/jdk1.7.0_09/bin/java 300
sudo update-alternatives--install/usr/bin/javac Javac/usr/lib/jdk1.7.0_09/bin/javac 300
sudo update-alternatives--config java
sudo update-alternatives--config javac

The first two lines add Java commands and Javac files to the system's default Java and Javac commands.
The last two lines select the Java and Javac providers to use from the Java and Javac Command group (if only one Java and Javac file is installed, you can omit the two lines.) )

5. Check if the installation is successful
Java-version

appear similar to
Java Version "1.7.0_09"
Java (TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot (TM) 64-bit Server VM (build 23.5-b02, Mixedmode)
Output, it means you succeeded ...


Reference to: Hello Broken Army's Blog Park
Http://www.cnblogs.com/hellopojun/archive/2012/07/12/2588676.html

Installation and configuration of JDK environment under ubuntu-12.04.1-desktop-x64

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.