First, install JDK reference post
Installing JDK with Yum (CentOS)
1. See which JDK versions are available in the Yum Library
12345678910111213141516171819 |
[[email protected] ~]
# yum search java|grep jdk
ldapjdk-javadoc.x86_64 : Javadoc
for
ldapjdk
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk.x86_64 : The Mozilla LDAP Java SDK
|
2. Select a version to install
We install the 1.7 version here
1 |
[[email protected] ~] # yum install java-1.7.0-openjdk |
After the installation is complete, the default installation directory is:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
3. Setting Environment variables
1 |
[[email protected] ~] # vi /etc/profile |
Add the following content:
123456 |
#set java environment JAVA_HOME= /usr/lib/jvm/java-1 .7.0-openjdk-1.7.0.75.x86_64 JRE_HOME=$JAVA_HOME /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 |
Let the changes take effect:
1 |
[[email protected] java] # source /etc/profile |
3. Verification
Ditto.
Note: Due to the use of Yum to install the JDK, the system takes into account multiple versions of the problem, it will be version control with alternatives. Initially, the corresponding version of the JDK is installed in the/usr/lib/jvm/and will be registered in the alternatives, and in the/etc/alternatives directory will produce some links to the newly installed JDK version in/usr/lib/jvm/.
Below the/usr/bin there will be a corresponding file linked to/etc/alternatives. For example,/usr/bin will have a link file below the Java mapping relationship as follows:
12 |
/usr/bin/java- > /etc/alternatives/java /etc/alternatives/java- > /usr/lib/jvm/jre-1 .7.0-openjdk.x86_64 /bin/java |
This allows the Java command to function without setting the environment variable. However, if you want to set environment variables for Tomcat or other software.
Similarly, if a new version of the JDK is installed, it will be re-linked to the latest installed JDK version. Of course, you can also use alternatives to modify the version you want to use.
Specific methods can be referenced: "Using Linux alternatives to manage multiple versions of software"
Second, install port view command to see which ports occupy
Yum Install wget
Yum Install Net-tools
Third, Port view
NETSTAT-APN, view all process and port usage
Netstat-apn|grep 8080 See the specific port number
Four, the firewall problem immediately effective, restart after the failure
need to install Yum Install iptables-services in order to use iptables Viewing Firewalls
Status View: Service iptables status
Open: Service iptables start
Close: Service iptables stop
Linux System Environment Setup