CentOS setting default JDK step details and commands

  • 2020-05-27 07:45:11
  • OfStack

Set the default JDK under CentOS

Recently, after installing the opnjdk-devel version with the yum source, I checked it with the command ll /etc/alternatives/Java and found that it pointed to the jre directory instead of jdk. Here, I set it to point to the jdk directory.

Set the default JDK under CentOS

Execute the command:

[root @ exkPicture ~] # alternatives � install/usr/bin/Java java/usr/java/jdk1. 7.0 / bin java 2

Note: the syntax for alternatives is shown here

Execute the command:

[root@exkPicture ~] # alternatives --config java

Select the default jdk, and the "+" is the default jdk

*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/java/jdk1.7.0/bin/java

2. Configure JAVA environment Settings

[root @exkPicture ~] # vim /etc/profile

Add the following at the end of the file:


export JAVA_HOME=/usr/java/jdk1.7.0
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Save after exit

source /etc/profie

The deployment is now complete.

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: