Installation of the Centos system Java environment

Source: Internet
Author: User

Java Installation

Install Sun's JDK:

Official website: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Create a Java directory under/usr in case the Java program is installed in this directory, enter the following command:

[Email protected] ~]# mkdir/usr/java/

Upload the downloaded files to the/usr/java/directory:

[[email protected] ~]# cd/usr/java/[[email protected] java]# ll-rw-r--r--1 root root 185540433 July   8 07:16 jdk-8u131- Linux-x64.tar.gz

Unzip the file and replace the directory name:

[[Email protected] java]# tar zxvf jdk-8u131-linux-x64.tar.gz[[email protected] java] #mv jdk1.8.0_131//usr/java/jdk

Finally, the environment variable is set. Enter the following command to enter the configuration file:

[Email protected] ~]# vim/etc/profileexport PATH USER LOGNAME MAIL HOSTNAME histsize histcontrolexport java_home=/usr/ja Va/jdkexport path= $JAVA _home/bin: $PATHexport classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Execute the configuration file so that it takes effect immediately and enter the following command:

[Email protected] ~]# Source/etc/profile

To view the current version:

[[email protected] ~]# Java-versionjava version "1.8.0_131" Java (TM) SE Runtime Environment (build 1.8.0_131-B11) Java Hots Pot (TM) 64-bit Server VM (build 25.131-b11, Mixed mode)

To create a Java program for testing:

[[email protected] ~]# vim Helloworld.javapublic class helloworld{public        static void main (String []args) {                System.out.print ("Hello world\n");}}

Perform validation:

[Email protected] ~]# javac Helloworld.java [[email protected] ~]# java Helloworldhello World

  

Centos system Java Environment installation

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.