Java installation and configuration under Linux

Source: Internet
Author: User

First, uninstall the system comes with the JDK

If Linux has its own openjdk, we need to uninstall it, or we can install the JDK directly.

To see if the Linux-brought JDK is installed, enter the following command to view the Java version information.

Java-version
Then enter the following command to view the JDK information.

Rpm-qa|grep Java

For example, it outputs

Java-1.5.0-openjdk-1.5.0-1.23.1.1.1.el.x86_64

Tzdata-java-2012c-l.el6.noarch

Above just for example, there may be multiple items)

At this point we can uninstall the JDK using the Yum command

Yun-y Remove java-1.5.0-openjdk-1.5.0-1.23.1.1.1.el.x86_64

Yun-y Remove Tzdata-java-2012c-l.el6.noarch

Ii. Installation of JDK

1. Download the JDK we need.

Jdk:

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

Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

I downloaded the jdk-7u79-linux-x64.tar.gz.

2. Create the installation directory directory for the Java program

Mkdir/usr/java

3. Download the tar.gz copy to the/usr/java directory

CP Jdk-7u79-linux-x64.tar.gz.gz/usr/java

4. Go to the/usr/java directory and view the directory's files

Cd/usr/java
Ls-a

5. Unzip the file and enter the following command

TAR-ZXVF jdk-7u79-linux-x64.tar.gz

After extracting, a new directory will be generated in the/usr/java directory jdk1.7.0_79

6. Configure the environment variable, enter the following command to enter the configuration file

Vi/etc/profile

Find Export PATH USER LOGNAME MAIL HOSTNAME histsize Histcontrol this line

(Press the A key, enter insert edit mode) to comment out this line (preceded by #) and add three lines of configuration information, as follows:

#export PATH USER LOGNAME MAIL HOSTNAME histsize Histcontrol
Export java_home=/usr/java/jdk1.7.0_79
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools/jar

After modifying, press ESC to return to command mode, and then enter: Wq Save and Exit VI Edit

7. In order for the configuration file to take effect immediately, enter the following command:

Source/etc/profile

8. Then verify that Java is installed successfully, enter the following command: Java-version

If the Java version information is output, the installation is successful, otherwise the profile may be misconfigured

Other Notes

1. If you are a non-root user, you typically have insufficient permissions if you have an error message similar to Permission denied. You can modify folder permissions, for example:
chmod +x/usr/java/jdk1.7.0_79/bin/java


2. Sometimes you want to use RPM to install the java,rpm installation command for
RPM-IVH jdk-7u79-linux-x64.rpm

3. Linux *.tar.gz File Decompression command description

Compression command:
TAR-ZCVF compressed file name. tar.gz Compressed file name

Decompression command:
TAR-ZXVF compressed file name. tar.gz

Java installation and configuration under Linux

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.