Installing Java 1.8 and Tomcat 8 in Centos 7

I have been setting up our servers in Amazon AWS and found that installing JDK is not as straightforward as I thought it would be ūüôā

I had to do some googling before I could settle down on a method to setup and run tomcat 8 using jdk 1.8 in centos. Putting the steps below for reference to anyone who is trying to achieve the same in AWS:

Setting up Java 8

  1. Login into server
  2. Execute cd /opt
  3. Install wget using  yum install wget 
  4. wget¬†–no-cookies¬†–no-check-certificate¬†–header¬†“Cookie:¬†;¬†oraclelicense=accept-securebackup-cookie”¬† 

    NOTE : Please change the version if using a different version

  5. Run the command :
  6. Check the java version using
  7. Set the global environments
    export JAVA_HOME=/usr/java/jdk1.8.0_45/
    export PATH=$PATH:$JAVA_HOME
  8. Add to the startup profile
    vi /etc/profile.d/
  9. Put the following content in the file

    export PATH JAVA_HOME
    export CLASSPATH=.

  10. Change the permission from all
    chmod +x /etc/profile.d/

  11. Set the environment variables permanently
    source /etc/profile.d/



Setting up Apache Tomcat 8

Setting up of tomcat is pretty straightforward. We just need to have the latest version downloaded and extracted to /opt

  1. Login into the server
  2. cd /opt
  3. wget Replace the link with the latest version 
  4. Extract the tar file
    tar xzf apache-tomcat-8.0.21.tar.gz
  1. Setup the environment variable for the catalina home
    source ~/.bashrc
  1. Start the tomcat from bin folder

Reference :


You may also like...

1 Response

  1. May 19, 2016

    […] I am currently using centos 7 with Java 8 installed . The web container used is Tomcat8. You can read about the setting up of Java 8 and Tomcat 8 here. […]

Leave a Reply

Your email address will not be published. Required fields are marked *