Create a new file to write the code to run on computer start-up:
Open a new file using the following command from terminal: sudo vi /etc/init.d/tomcat
or sudo gedit /etc/init.d/tomcat
Copy the below code in the new tomcat file opened: # Tomcat auto-start # description: Auto-starts tomcat # processname: tomcat # pidfile: /var/run/tomcat.pid export JAVA_HOME=/usr/lib/jvm/java-6-sun case $1 in start) sh /usr/local/tomcat/bin/startup.sh ;; stop) sh /usr/local/tomcat/bin/shutdown.sh ;; restart) sh /usr/local/tomcat/bin/shutdown.sh sh /usr/local/tomcat/bin/startup.sh ;; esac exit 0NOTE: change the path mentioned in above code, if the file path is different on your system.
Make the script executable by running the chmod command: sudo chmod 755 /etc/init.d/tomcat
Link this script to the startup folders with a symbolic link:
sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat
Restart the system and tomcat start automatically:
Open any browser and type localhost:8080/ to see the tomcat home page.