Friday, September 12, 2014

Installing Java-7 and Apache Tomcat/8.0.12 on CentOS-6.5


I. JAVA:

1. Search JDK in the yum repositories;

# yum search java | grep -i --color JDK
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser
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
ldapjdk.x86_64 : The Mozilla LDAP Java SDK

2. Once found, install the required version (if the search does yield any result then please download
         and install manually).

# yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel

3. Check if there are already installed versions of Java;

# alternatives --config java

There is 1 program that provides 'java'.

Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number:

4. Set JAVA_HOME varaiable and include Java binaries in the system PATH;

# vi /etc/profile

## Set JAVA_HOME
JAVA_HOME="/usr/lib/jvm/jre-1.7.0-openjdk.x86_64"
export JAVA_HOME

## Set JAVA Path
PATH=$PATH:/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin

5. Execute the file so that the new changes are reflected on the system;
# source /etc/profile

6. Test Java:
A. # echo $JAVA_HOME
/usr/lib/jvm/jre-1.7.0-openjdk.x86_64

B. # cat > HelloWorld.java
  public class HelloWorld {
public static void main(String[] args) {
         System.out.println("Hello, World! ");
    }
  }

# javac HelloWorld.java
# java HelloWorld
Hello, World!

II. Apache Tomcat

1. Download Apache Tomcat/8.0.12:
# wget http://apache.mirrors.pair.com/tomcat/tomcat-8/v8.0.12/bin/apache-tomcat-8.0.12.tar.gz

2. Extract:
# tar -xvzf apache-tomcat-8.0.12.tar.gz

3. I moved the extracted directory under /usr/local;
# mv apache-tomcat-8.0.12 /usr/local/

4. # /usr/local/apache-tomcat-8.0.12/bin/startup.sh
Using CATALINA_BASE:   /usr/local/apache-tomcat-8.0.12
Using CATALINA_HOME:   /usr/local/apache-tomcat-8.0.12
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.12/temp
Using JRE_HOME:        /usr/lib/jvm/jre-1.7.0-openjdk.x86_64
Using CLASSPATH:       /usr/local/apache-tomcat-8.0.12/bin/bootstrap.jar:/usr/local/apache-
        tomcat-8.0.12/bin/tomcat-juli.jar
Tomcat started.

No comments: