Install JDK 1.7.0 _ 45 in Ubuntu

Source: Internet
Author: User

Install the * .tar.gz package of jdk on Ubuntu
First decompress * .tar.gz

The specific method is tar-xzvf * .tar.gz.

The following uses my own installation version (jdk1.7.0 _ 45) as an example:

1. decompress the Installation File: tar-xzvf jdk-7u45-linux-x64.tar.gz

Decompress the package to obtain the jdk1.7.0 _ 45 folder.

2. Move it to the/usr/directory and run the following command: sudo mv jdk1.7.0 _ 45/usr/

So far, jdk has been installed.

Configure the environment variables as follows:

1. Use the export command to directly set it in shell:

Export JAVA_HOME =/usr/jdk1.7.0 _ 45
Export JRE_HOME =/usr/jdk1.7.0 _ 45/jre
Export PATH = $ PATH: $ JAVA_HOME/bin: $ JRE_HOME/bin
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar: $ JRE_HOME/lib

Of course, this setting of environment variables takes effect only for the current shell. If you log on from another shell, you cannot use the variable you just set. So the best way is to modify the. bashrc file.

2. Modify the environment variable in the. bashrc file:
The. bashrc file is a hidden file under the root directory of the user;
For example, if your user name is user, your home directory is in/home/user
In the console, enter:
Cd ~
Ls-a (list all files in the current directory)
You can see the. bashrc file.
You can use vi or your favorite editor for editing:

# Vi. bashrc
Set JAVA_HOME =/usr/jdk1.7.0 _ 45
Export JAVA_HOME
Set JRE_HOME =/usr/jdk1.7.0 _ 45/jre
Export JRE_HOME
Set PATH = $ PATH: $ JAVA_HOME/bin: $ JRE_HOME/bin
Export PATH
Set CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar: $ JRE_HOME/lib
Export CLASSPATH
3. Of course, you can also change/etc/profile. However, this setting is not recommended because it will take effect for your shell and affect system security.

# Vi/etc/profile

Add the following in the profile file:

JAVA_HOME =/usr/jdk1.7.0 _ 45
JRE_HOME =/usr/jdk1.7.0 _ 45/jre
PATH = $ PATH: $ JAVA_HOME/bin: $ JRE_HOME/bin
CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar: $ JRE_HOME/lib
Export JAVA_HOME JRE_HOME PATH CLASSPATH
After adding, save and exit. The third option is to restart the server;

4. Verify that the variable settings take effect (log out before verification and log on again );

5. Set the environment to OK to see if JDK works normally. Let's write a test file Hello. java.

// Hello. java
Public class Hello {

Public static void main (String [] args)
{
System. out. println ("Hello world! ");
}

}

OK. The test is successful. Now jdk can be used!

Install JDK 7 In Ubuntu (with Clojure download)

Install JDK 12.04 in Ubuntu

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.