Install JDK 8 in CentOS

Source: Internet
Author: User

Install JDK 8 in CentOS

Install JDK 8 in CentOS

Install JDK 8

1. Go to renewal.

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

3. Execute the command tar zxvf jdk-8u60-linux-x64.tar.gz for decompression, decompress the/usr/java directory and add the jdk1.8.0 _ 60 folder.

4. After completing the preceding steps, JDK installation is complete. Configure the environment variables.

Configure Environment Variables

1. Run vim/etc/profile to edit the profile file.

2. Add the following content at the bottom of/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. The environment variable configuration is complete. Note that $ JAVA_HOME/bin must be placed in front of the PATH during configuration. Otherwise, when using java commands, the system will find the previous java and will not look down. In this way, the directory for running the java executable file is not under $ JAVA_HOME/bin, but under other directories, it will cause a lot of problems.

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

Command Test

1. If you use the javac command, the command not found error will not occur.

2. If java-version is used, the version is java version "1.8.0 _ 60 ".

3. Check whether your configuration is correct.

Echo $ JAVA_HOME

Echo $ CLASSPATH

Echo $ PATH

Code Testing

Create a new file Hello. java in your working directory. Write the following content:

Public class Hello {
Public static void main (String [] args ){
System. out. println ("Hello World ");
}
}

Run the following command. If the following result is displayed, jdk installation is complete.

# Javac Hello. java
# Java-cp. Hello

Hello World

Of course, the jdk8 we have installed should test the features of jdk8. You can use the stream unique to JDK 8 for testing. The Code is 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 ");
MyList. stream (). filter (x-> x. contains ("a"). map (x-> x. toUpperCase ())
. ForEach (x-> System. out. println (x ));
}
}

Run the following command. The result shows that the installation is correct.

# Javac TestLambda. java
# Java-cp. TestLambda

Install JDK 1.8.0 _ 25 on Ubuntu 14.04 and configure Environment Variables

Build a JDK environment using CentOS

Install JDK 1.8.0 _ 25 on Ubuntu 14.04 and configure Environment Variables

Install Oracle JDK 14.04 on Ubuntu 1.8 LTS

CentOS6.3 install JDK and environment Configuration

Install JDK 8 on Ubuntu 14.04

Install JDK graph analysis in Ubuntu

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.