Install JDK1.8 in RHEL6.5
Note:
1. jdk1.8 is installed in this article, and the rpm package is used for installation. OS: RHEL6.5
2. By default, the rpm Installation Method installs jdk on the/usr/java/jdk1.8xxx path. If you want to install JDK in a specific path, you must install jdk in source code mode.
Steps:
1. Download the rpm file JDK1.8 from the official website and upload it to the linux Server (any directory)
2. Run the rpm command to install
[Root @ localhost ~] # Rpm-ivh jdk-8u151-linux-x64.rpm
3. Set the environment variable (the global environment variable is modified here)
[Root @ localhost java] # vi/etc/profile
Add the following content to the opened profile file:
# Set java environment
JAVA_HOME =/usr/java/jdk1.8.0 _ 151
JRE_HOME =/usr/java/jdk1.8.0 _ 151/jre
CLASS_PATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar: $ JRE_HOME/lib
PATH = $ PATH: $ JAVA_HOME/bin: $ JRE_HOME/bin
Export JAVA_HOME JRE_HOME CLASS_PATH PATH
The figure is as follows:
Run the source command to make the new environment variable take effect:
[Root @ localhost java] # source/etc/profile
4. Verify
Method 1:
[Root @ localhost java] # java-version
Java version "1.8.0 _ 151"
Java (TM) SE Runtime Environment (build 1.8.0 _ 151-b12)
Java HotSpot (TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
The figure is as follows:
Method 2:
Create a test file Hello. java in any directory and grant the executable permission. The file content is as follows:
Class Hello
{
Public static void main (String [] args)
{
System. out. println ("Hello world! ");
}
}
Then execute the following two commands in sequence for testing:
[Root @ localhost/data] # javac Hello. java # compile
[Root @ localhost/data] # java Hello # Run
Hello world
Figure:
Output Hello world !, The test is successful.
Configure JDK environment variable https://www.bkjia.com/Linux/2017-01/139212.htm under Linux Virtual Machine
Install JDK 1.8 https://www.bkjia.com/Linux/2016-12/138940tm on Ubuntu
CentOS7 configure custom JDK https://www.bkjia.com/Linux/2017-06/144979.htm
Ubuntu 16.04 LTS configuration JDK1.8 problems and solve notes https://www.bkjia.com/Linux/2017-02/140138.htm
Easy to understand on CentOS 6.7 install JDK getting started tutorial https://www.bkjia.com/Linux/2017-12/149877.htm
CentOS 7 installation and configuration jdk-8u162 https://www.bkjia.com/Linux/2018-03/151326.htm
This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151401.htm