Installing JDK8
Go to http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to download the JDK installation file jdk-8u60-linux-x64.tar.gz.
Create a new/usr/java folder, place the jdk-8u60-linux-x64.tar.gz under the folder, and switch to the/usr/java directory.
Execute the command tar zxvf jdk-8u60-linux-x64.tar.gz to extract the Jdk1.8.0_60 folder after extracting/usr/java directory.
Through the above steps, the JDK installation is complete. The following begins configuring environment variables.
Configuring Environment variables
Executes the command Vim/etc/profile edit the profile file.
Add the following at the bottom of the/etc/profile:
Java_home=/usr/java/jdk1.8.0_60
Path= $JAVA _home/bin: $PATH
Classpath= $JAVA _home/jre/lib/ext: $JAVA _home/lib/tools.jar
Export PATH java_home CLASSPATH
Above, the environment variable configuration is complete. Note that the path in the configuration, it is necessary to put $java_home/bin in front, or use the Java command, the system will find the previous Java, do not look down. In this way, the JAVA executable file run directory is not $java_home/bin, and in other directories, will cause a lot of problems.
Execute command source/etc/profile the profile file to take effect immediately.
Command test
With the Javac command, no command not found error occurs.
With Java-version, a version of Java Edition "1.8.0_60" appears.
See if your configuration is correct.
Echo $JAVA _home
Echo $CLASSPATH
Echo $PATH
Code testing
Create a new file Hello.java in your own working directory. Write the following content:
public class hello{public static void Main (string[] args) {System.out.println ("Hello World"); } }
Execute the command below and if you get the following result, the JDK installation is complete.
# Javac Hello.java # JAVA-CP. Hello
Hello World
Of course, we installed the JDK8, should test the characteristics of the JDK8. You can use the JDK8-specific stream to test the code as follows:
Import java.util.arrays; import java.util.iterator; import java.util.List; import java.util.function.Consumer; import java.util.function.function; import java.util.function.predicate; public class testlambda { Public static void main (String[] args) { // aggregate operations list<string> mylist = arrays.aslist ("Zhangsan", "Lisi", "Wangwu", "Liuliu"); &nBsp; mylist.stream (). Filter (X -> x.contains ("a")). Map (X -> x.touppercase ()) .foreach (X&NBSP;->&NBSP;SYSTEM.OUT.PRINTLN (x)); }}
Run with the following command to get the results, stating that there is no problem with the installation.
# Javac Testlambda.java # JAVA-CP. Testlambda
Zhangsan
Wangwu
This article is from the SQL Server deep dives blog, so be sure to keep this source http://ultrasql.blog.51cto.com/9591438/1694884
Installing the JDK8 under CentOS