JDK1.8 is installed in RHEL6.5 environment for your reference. The specific content is as follows
Note:
1. The installation of jdk1.8 in this article is used to install it in the rpm package.
2.rpm installation method will install jdk on the /usr/java/jdk1.8xxx path by default. If you want to install JDK on a specific path, you need to install it in source code.
step:
1. Download the rpm file of JDK1.8 on the official website and upload it to the linux server (any directory)
2. Use rpm command to install
[root@localhost ~]#rpm -ivh jdk-8u151-linux-x64.rpm
3. Set environment variables (I am modifying the global environment variable here)
[root@localhost java]# vi /etc/profile
Add the following content to the open profile file
#set java environmentJAVA_HOME=/usr/java/jdk1.8.0_151JRE_HOME=/usr/java/jdk1.8.0_151/jreCLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/libPATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/binexport JAVA_HOME JRE_HOME CLASS_PATH PATH
The illustration is as follows:
Then use the source command to make the newly modified environment variable take effect:
[root@localhost java]# source /etc/profile
4. Verification
Method 1:
[root@localhost java]# java -versionjava 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 illustration is as follows:
Method 2:
Create a new test file Hello.java in any directory and give executable permissions. The contents in the file are as follows:
class Hello{public static void main(String[] args){System.out.println("Hello world!");}}Then execute the following two commands in turn to test:
[root@localhost /data]# javac Hello.java #Compiled [root@localhost /data]# java Hello #Running Hello world
Illustration:
Output Hello world!, the test was successful.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.