Checking if JAVA is already installed in your system¶
Follow this step to check if Java software development kit (JDK) is already installed in your system.
To determine if JAVA SDK is already installed in your system, run the following command from command prompt.
dpkg –get-selections | grep sun-java
This should give you this output if you already installed java:
sun-java6-bin install sun-java6-jdk install sun-java6-jre install
Install JAVA SDK¶
If that command has no results or a previous version is installed, you’ll want to install the latest version with this command:
sudo apt-get install sun-java6-jdk
Set up the JAVA_HOME environment variable¶
Tomcat requires setting the JAVA_HOME variable. The best way to do this is to set it in your .bashrc file. The better method is editing your .bashrc file and adding the bolded line there. You’ll have to logout of the shell for the change to take effect.
Add the following line:
Now we’ll download and extract Tomcat from the apache site. You should check to make sure there’s not another version and adjust accordingly.
tar xvzf apache-tomcat-6.0.14.tar.gz
The best thing to do is move the tomcat folder to a permanent location. I chose /usr/local/tomcat, but you could move it somewhere else if you wanted to.
sudo mv apache-tomcat-6.0.14 /usr/local/tomcat
Starting and shutting down Tomcat¶
To startup the tomcat server, run the startup.sh file.
To shut down the tomcat server, run the shutdown.sh file.
Verifying Tomcat installation¶
To verify that tomcat is installed properly, start the server as explained above, open the web browser and access the following URL.
You should see the default Tomcat welcome page as shown here.