How to install JDK under CentOS

Source: Internet
Author: User
Tags centos

1, download JDK installation package: jdk-7u5-linux-i586.rpm (32bit)

· Download Address: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1637583.html

· Put in/tmp directory

2. Install JDK with rpm (i.)

· [Root@c1091test ~]# cd/tmp//To/tmp directory

· [Root@c1091test tmp]# rpm-i jdk-7u5-linux-i586.rpm//install JDK

· Unpacking JAR files ...

· Rt.jar ...

· Jsse.jar ...

· Charsets.jar ...

· Tools.jar ...

· Localedata.jar ...

· Plugin.jar ...

· Javaws.jar ...

· Deploy.jar ...

· [Root@c1091test tmp]# Ls/usr/java//See if JDK is installed, you can see that it is already installed in the/usr/java directory

· Default JDK1.7.0_05 Latest

· [Root@c1091test tmp]# VI ~/.bash_profile//configure Java environment variables

3. Install JDK with RPM (II.)

· The ~/.bash_profile file is modified as follows:

· #. Bash_profile

· # get the aliases and functions

· If [f ~/.BASHRC]; Then

· . ~/.bashrc

· Fi

· # User specific environment and startup programs

· Java_home=/usr/java/jdk1.7.0_05

· Classpath=.: $JAVA _home/lib/tools.jar: $JAVA _home/lib/dt.jar

· Path= $PATH: $HOME/bin:java_home/bin: $JAVA _home/jre/bin:/sbin

· Export PATH java_home CLASSPATH

· Unset USERNAME

· Press ESC to enter: Wq save exit, if the input Java and javac can run correctly means the installation is successful. Let's do a test to see if the installation is successful

4. Test whether the JDK is installed successfully

· Navigate to/tmp directory first:

· Write a Helloworld.java file for testing

public class HelloWorld

{

public static void Main (String args[])

{

System.out.println ("helloworld!!");

}

}

[Root@localhost/]# VI Helloworld.java//write as above program

[Root@c1091test tmp]# Javac Helloworld.java

§[root@c1091test tmp]# Java HelloWorld

§helloworld!!

· If you can see the information above, the installation is successful

Related Article

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.