UbuntuJava7SDK environment variable configuration

Source: Internet
Author: User
1. Go to the official Oracle website to download java7sdkhttp: // response. Generally, there is no jvm folder in the/usr/lib folder.

1. Go to the official Oracle website to download the Java 7 sdk

Http://www.oracle.com/technetwork/java/javase/downloads/index.html

Here I downloaded the latest java1.7.0 _ 07

2. Extract

Decompress the downloaded jdk-7u7-linux-i586.tar.gz and put it in the/usr/lib/jvm folder. Generally, the/usr/lib Folder does not have a jvm folder. You need to create it manually. The author uses the root administrator account to log on (sudo passwd root), so it can be directly created in the lib folder. For non-root login, run the following command:

Sudo mkdir/usr/lib/jvm

3. Modify Environment Variables

Enter at the terminal:

Vim ~ /. Bashrc

Vim commands are unfamiliar. You can search for information on the Internet. There are many

Then add the following code (I insert ):

Export JAVA_HOME =/usr/lib/jvm/java1.7.0 _ 07
Export JRE_HOME =$ {JAVA_HOME}/jre
Export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
Export PATH =$ {JAVA_HOME}/bin: $ PATH

Save and exit (ESC +: wq), and enter the following command to make it take effect immediately

Source ~ /. Bashrc

Ps:/etc/profile setting method is valid for all logged-on users .~ /. Bashrc is only valid for the current user.

Both of the above are configuration files. After the instance is started, the system will first read/etc/profile and then read ~ /. Bashrc. Different users ~ The/. bashrc file can have different settings,

The/etc/profile is shared and can be modified only by the root user .~ /. Bashrc applies append coverage to/etc/profile.

4. Test

Enter the java-version command. If the result is as follows, the installation is correct.

Root @ ubuntu :~ # Java-version
Java version "1.7.0 _ 07"
Java (TM) SE Runtime Environment (build 1.7.0 _ 07-b10)
Java HotSpot (TM) Server VM (build 23.3-b01, 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.