Install JDK and set Java environment variables in Linux

Source: Internet
Author: User

Install JDK in Linux as follows:

Step 1: Check whether the built-in JDK of Linux is installed

(1) view the installed JDK:

# Rpm-Qa | grep JDK plugin to view JDK information or directly execute

Or

# Rpm-Q JDK

 

Or

# Java-version

 

(2) rpm-Qa | grep JDK uninstall:

 

(3) If the rpm-e RPM package name (as shown above) has a dependency, uninstall the upper-layer package first.

 

Step 2: Install JDK

<1> download jdk-1_5_0_14-linux-i586-rpm.bin or jdk-1_5_0_14-linux-i586.bin from sun

Create a Java folder under/USR and put the installation package in the/usr/Java directory.

# Mkdir/usr/Java

<2> install JDK

# Cd/usr/Java (mkdir Java-this directory needs to be created)

① Install jdk-1_5_0_16-linux-i586-rpm.bin files

# Chmod 777 jdk-1_5_0_16-linux-i586-rpm.bin supervisor modified to Executable

#./Jdk-1_5_0_16-linux-i586-rpm.bin accept select YES to agree to the above agreement

# Rpm-IVH jdk-1_5_0_16-linux-i586.rpm configure Select Yes until installation is complete

② Install jdk-1_5_0_16-linux-i586.bin files

# Chmod A + x jdk-1_5_0_16-linux-i586.bin grants the current user permission to execute

#./Jdk-1_5_0_16-linux-i586.bin plugin Select Yes until installation is complete

 

Step 3: Configure Environment Variables

<1> # vi/etc/profile

<2> Add the following lines at the end:

Export java_home =/usr/Java/jdk1.5.0 _ 16

Export classpath =.: $ java_home/JRE/lib/RT. jar: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar

Export Path = $ path: $ java_home/bin

<3> # source/etc/profile takes effect after execution

 

Step 4: Test JDK

# Vi hello. Java

Public class Hello {

Public static void main (string ARGs [])

{

System. Out. println ("Hello world! ");

System. Out. println ("2009/2/19 ");

}

}

# Javac hello. Java

# Java hello

 

Hello world!

2009/2/19

 

The installation is successful!

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/candle806/archive/2009/05/14/4187017.aspx

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.