First step: Uninstall the JDK from the old Linux
① viewing native JDK versions
Java code
- Java-version
The results are as follows
Java code
- Java version "1.6.0"
- OpenJDK Runtime Environment (build 1.6. 0-B09)
- OpenJDK 64-bit Server VM (build 1.6. 0-B09, Mixed mode)
② Uninstall the OpenJDK that comes with the machine and install Sun's JDK.
Java code
- Rpm-qa | grep java
The following information is displayed:
Java code
- java-1.4. 2-gcj-compat-1.4. 2.0-40JPP. the
- java-1.6. 0-openjdk-1.6. 0.0-1.7.b09.el5
Unloading:
Java code
- RPM-E--nodeps java-1.4. 2-gcj-compat-1.4. 2.0-40JPP. the
- Rpm-e--nodeps java-1.6. 0-openjdk-1.6. 0.0-1.7.b09.el5
If OpenJDK source cannot be found, you can also uninstall this
Java code
- Yum-y remove Java java-1.4. 2-gcj-compat-1.4. 2.0-40JPP. the
- Yum-y Remove Java java-1.6. 0-openjdk-1.6. 0.0-1.7.b09.el5
Step Two: Install the JDK
http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html (JDK download)
① download Jdk-1_5_0_14-linux-i586-rpm.bin or Jdk-1_5_0_14-linux-i586.bin from Sun
Create a new Java folder under/usr and place the installation package in the/usr/java directory
Java code
- Mkdir/usr/java
② Installing the JDK
Java code
- # Cd/usr/java
If the Jdk-1_5_0_14-linux-i586-rpm.bin file is installed
Java code
- # chmod 777 jdk-1_5_0_14-linux-i586-rpm.bin← modified to executable
- #./jdk-1_5_0_14-linux-i586-rpm.bin← Select Yes to agree to the above agreement
- # RPM-IVH jdk-1_5_0_14-linux-i586.rpm← Select Yes until installation is complete
If the. bin file is installed
Java code
- # chmod a+x jdk-1_5_0_14-linux-i586.bin← enables the current user to have Execute permissions
- #./jdk-1_5_0_14-linux-i586.bin← Select Yes until installation is complete
(Refer to Blog http://johnsz.blog.51cto.com/525379/694052)
Step Three: Configure environment variables
①# Vi/etc/profile
② Add the following lines at the end:
Java code
- Export JAVA_HOME=/USR/JAVA/JDK1. 6.0_10
- Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
- Export path= $PATH: $JAVA _home/bin
③# reboot← Restart machine configuration effective
Fourth step: Turn off the firewall or add ports
Java code
- Vi/etc/sysconfig/iptables Open the configuration file by adding the following statement:
- -A input-p tcp-m state--state new-m TCP--dport 8080-j ACCEPT
- Restarting the firewall
- /etc/init.d/iptables restart
- View port Status
- /etc/init.d/iptables status
(Refer to Blog http://blog.csdn.net/you_jinjin/article/details/7262461)
Fifth step: Project Packaging operation
Java code
- Java-jar Projectname.jar
Sixth step: Suspend the process in the background
Java code
- Nohup Java-jar Projectname.jar
After running, the program creates a log file in the same directory as the jar file, records the console display information, and closes the command-line window, and the service continues to run.
(Refer to Blog http://303i.com/article/2013/11/10/1111.html)
Deploying Java Services on CentOS