After RHEL and CentOS Linux use the yum command, install OpenSDK to/usr/lib/jvm/directory:
[[email protected] ~]# ls -l/usr/lib/jvm/
The output is as follows:
Total 4DRWXR-XR-X. 3 root Root 4096 Feb 24 17:00 java-1.7.0-opnjdk-1.7.0.x86lwxrwxrwx. 1 root root 21 Feb 24 17:00 JR rwxrwxrwx. 1 Root Root 27 Feb 24 17:00 JRE-1.7.0-> /etc/alternatives/jre_1.7.0lrwxrwx. 1 Root Root 38 Feb 24 17:00 JRE-1.7.0-opnjdk.x86_64-> Java-1.7.0 -Penjdk-1.7.0.51.x86_64/JRELRWXRWX. 1 root root 29 Feb 24 17:00 jre-peenjdk->/etc/alternatives/jre_openjdkkkkk
Explanation: D in DRWXR-XR-X. The remaining L represents the link.
Set java_home to point to a directory containing a Java executable program (usually in Bin/Java). We use the CD command to enter the only directory under the JVM in Java-1.7.0-Openjdk-1.7.0.51.x86_64, and JRE-1.7.0-openjdk.x86_64 is pointing to Java-1.7.0-Openjdk-1.7 .0.51.x86_64 is the folder, so you can directly use the export command to point java_home to JRE-1.7.0-openjdk.x86_64.
Even using the Export command:
[[email protected] ~]# Export java_home =/usr/lib/jvm/java-1.7.0 -Penjdk-1.7.0.51.x86_64
But this can only be effective in the current session. Once you cancel the offline, it will fail.
So it is best to save it in the $ home/.bashrc file (this file is for designated users, if you are called a dabu user, then log in to use DABU users, and then enter the command: Echo $ home/.bashrc will show that you want you want Modified file path)
After finding this file, add a line to the bottom of the file, as follows:
export java_home =/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64
Save the close file after modification.
Or let all users on the system use Java (OPENJDK), then perform the following operations:
[[email protected] ~]# VI /ETC /Profile
Paste the following three lines into/etc/profile::
export java_home =/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.x86_64export Classpath =.: $ java_home/lib/rt.jar: $ java_home/lib/dt.jar: $ Java_home/ lib/Tools.jarexport Path = $ PATH: $ java_home/bin
Save and close, after, execute:
[[email protected] ~]# Source /ETC /Profile
Let the setting take effect immediately.
Enter the following command to confirm whether these three variables are set to what we want:
[[email protected] ~]# echo $ java_home [[email protected] ~]# echo $ classpath [[email protected] ~]# echo $ Path