Deploying Java Services on CentOS

Source: Internet
Author: User

First step: Uninstall the JDK from the old Linux

① viewing native JDK versions

Java code
    1. Java-version

The results are as follows

Java code
    1. Java version "1.6.0"
    2. OpenJDK Runtime Environment (build 1.6. 0-B09)
    3. 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
    1. Rpm-qa | grep java

The following information is displayed:

Java code
    1. java-1.4. 2-gcj-compat-1.4. 2.0-40JPP. the
    2. java-1.6. 0-openjdk-1.6. 0.0-1.7.b09.el5

Unloading:

Java code
    1. RPM-E--nodeps java-1.4. 2-gcj-compat-1.4. 2.0-40JPP. the
    2. 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
    1. Yum-y remove Java java-1.4. 2-gcj-compat-1.4. 2.0-40JPP. the
    2. 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
    1. Mkdir/usr/java

② Installing the JDK

Java code
    1. # Cd/usr/java

If the Jdk-1_5_0_14-linux-i586-rpm.bin file is installed

Java code
    1. # chmod 777 jdk-1_5_0_14-linux-i586-rpm.bin← modified to executable
    2. #./jdk-1_5_0_14-linux-i586-rpm.bin← Select Yes to agree to the above agreement
    3. # RPM-IVH jdk-1_5_0_14-linux-i586.rpm← Select Yes until installation is complete

If the. bin file is installed

Java code
    1. # chmod a+x jdk-1_5_0_14-linux-i586.bin← enables the current user to have Execute permissions
    2. #./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
    1. Export JAVA_HOME=/USR/JAVA/JDK1. 6.0_10
    2. Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
    3. Export path= $PATH: $JAVA _home/bin

③# reboot← Restart machine configuration effective

Fourth step: Turn off the firewall or add ports

Java code
    1. Vi/etc/sysconfig/iptables Open the configuration file by adding the following statement:
    2. -A input-p tcp-m state--state new-m TCP--dport 8080-j ACCEPT
    3. Restarting the firewall
    4. /etc/init.d/iptables restart
    5. View port Status
    6. /etc/init.d/iptables status

(Refer to Blog http://blog.csdn.net/you_jinjin/article/details/7262461)

Fifth step: Project Packaging operation

Java code
    1. Java-jar Projectname.jar

Sixth step: Suspend the process in the background

Java code
    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.