JDK8 is a product of Java. If you remember that the format of the previous mobile software installation package is JDK format, then you are old. Not to mention this, in short, JDK8 is widely used in Linux systems. This article will introduce the steps of installing JDK8 on CentOS system.
Installation JDK8
1. Download JDK installation file.
2. Create a new /usr/java folder, put 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 to decompress, after decompressing /usr/java directory more jdk1.8.0_60 folder.
4. Through the above steps, the JDK installation is complete. Let's start configuring the environment variables.
Configuring environment variables
1. Run the vim /etc/profile command to edit the profile file.
2. Add the following 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. Above, the environment variable configuration is complete. It should be noted that when configuring PATH, you must put $JAVA_HOME/bin in front. Otherwise, when you use the java command, the system will find the previous java, and then don't look down. This java executable directory is not running under $JAVA_HOME/bin, but in other directories, it will cause a big problem.
4. Execute the command source /etc/profile to make the profile file take effect immediately.
Command Test
1. Using the javac command, there is no command not found error.
2. Using java -version, the version is java version “1.8.0_60”.
3. See if your configuration is correct.
echo $JAVA_HOME
echo $CLASSPATH
echo $PATH
Code Test
Create a new one in your working directory The file Hello.java. Write the following:
public class Hello{
public static void main(String[] args){
System.out.println(“Hello World”) ;
}
}
Execute the command as follows. If you get the following result, the jdk installation is complete.
# javac Hello.java
# java -cp . Hello
Hello World
Of course, the jdk8 we installed should test the features of jdk8. You can use jdk8-specific stream to test, 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(&ldquo ;zhangsan”, “lisi”, “wangwu”,
“liuliu”);
myList.stream().filter(x -" x.contains(“a&rdquo ;)).map(x -》 x.toUpperCase())
.forEach(x -》 System.out.println(x));
}
}
Run the following command to get the result, indicating that there is no problem with the installation.
# javac TestLambda.java
# java -cp . TestLambda
The above is the step of installing JDK8 on the CentOS system, including the installation process and debugging process. I hope everyone can use JDK8 smoothly. If it is Red Hat system to install JDK8, you can refer to: RedHat download and install JDK method
Many people are familiar with Ubuntu shared file box Windows shared files, and know
In Linux system operation, many people dont know much about dmg file, but dont know how to create dm
In the KDE desktop environment of Ubuntu system, many users will encounter flashbac
In Linux system operation, S3QL can be used to create an encrypted file system that can store data o
Linux system hardware routing forwarding principle
RedHat how to install log4cxx log library
Linux system Vsftp 553 Could Not Create File error?
How to manage modules in the Linux kernel?
How Linux expands the number of file openers
What is the use of the Linux system pppsetup command?
How to install vsftpd server under Linux
Summary of tar commands in Linux system
How to install Linux using the pidstat command
How to check the version of Shell that Linux system is using?
What should I do if Win8.1 phone activation cannot input numbers?
Network connection automatically when booting
Where is the running window of the win8 system?
XP and Vista installed the same partition
How to safely install Vista system
How to adjust Windows 8 screen zoom through ATI graphics card
How does Win7 open system services? Methods for viewing system service information