Installing the JDK8 under CentOS

Source: Internet
Author: User

Installing JDK8


    1. 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.

    2. Create a new/usr/java folder, place the jdk-8u60-linux-x64.tar.gz under the folder, and switch to the/usr/java directory.

    3. Execute the command tar zxvf jdk-8u60-linux-x64.tar.gz to extract the Jdk1.8.0_60 folder after extracting/usr/java directory.

    4. Through the above steps, the JDK installation is complete. The following begins configuring environment variables.

Configuring Environment variables


    1. Executes the command Vim/etc/profile edit the profile file.

    2. 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

    3. 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.

    4. Execute command source/etc/profile the profile file to take effect immediately.

Command test


    1. With the Javac command, no command not found error occurs.

    2. With Java-version, a version of Java Edition "1.8.0_60" appears.

    3. 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;-&GT;&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

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.