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