How To Install Java And Tomcat On Ubuntu 16.046 min read
Now I want to share how to install java and tomcat on your ubuntu 16.04 server. This tutorial is manual installation process for installation java and tomcat. You can install java and tomcat any directory, if you use my guide. So let’s start for installation process.
★ How To Install WordPress On Ubuntu 20.04
★ How To Install DNS Server (Bind9) On Ubuntu 20.04
My server info :
Server IP : 10.66.50.10
Disk : 25 GB
RAM : 2 GB
vCPU : 2
Service : Java & Tomcat
Web : Tomcat
vJava : jdk-8u191
vTomcat : 8.0.53
Download Java from jdk-8u191 and download Tomcat 8.0.53. Must be account needed for java package download. After complete download and connect your server via ssh then upload this file.
Step #01: Server update and extract Java and Tomcat file.
[email protected]:~# apt update && apt-get upgrade [email protected]:~# apt install unzip [email protected]:~# mkdir -p /home/app/Java/jdk/ [email protected]:~# mkdir -p /home/app/Tomcat [email protected]:~# tar xf jdk-8u191-linux-x64.tar.gz [email protected]:~# unzip apache-tomcat-8.0.53.zip [email protected]:~# mv jdk1.8.0_191/ /home/app/Java/jdk/8.0.191 [email protected]:~# mv apache-tomcat-8.0.53 /home/app/Tomcat/8.0.53
Create setenv.sh file for environment variable.
[email protected]:~# vi /home/app/Tomcat/8.0.53/bin/setenv.sh
Insert below all text into setenv.sh file and save.
export JAVA_OPTS="-Dfile.encoding=UTF-8 -server -Xms1024m -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=256m"
For save press Esc type :wq press Enter.
Then run below command for select update file location.
[email protected]:~# update-alternatives --install "/usr/bin/javac" "javac" "/home/app/Java/jdk/8.0.191/bin/javac" 1 [email protected]:~# update-alternatives --install "/usr/bin/java" "java" "/home/app/Java/jdk/8.0.191/bin/java" 1 [email protected]:~# update-alternatives --set "javac" "/home/app/Java/jdk/8.0.191/bin/javac" [email protected]:~# update-alternatives --set "java" "/home/app/Java/jdk/8.0.191/bin/java" [email protected]:~# chmod -R 755 /home/app/
Step #02: Open profile file and add java file location.
[email protected]:~# vim /etc/profile
Insert below text into profile file.
JRE_HOME=/home/app/Java/jdk/8.0.191 PATH=$PATH:$JRE_HOME/bin export JRE_HOME export PATH
For save press Esc type :wq then press Enter.
Step #03: Setup tomcat heap memory.
[email protected]:~# vim /home/app/Tomcat/8.0.53/bin/catalina.sh
Insert below text into catalina.sh file.
#tomcat heap memory set
JAVA_OPTS="-Dfile.encoding=UTF-8 -server -Xms1024m -Xmx2048m -XX:PermSize=64m -XX:MaxPermSize=256m -Djava.awt.headless=true -XX:+UseParallelGC -XX:MaxGCPauseMillis=100"
Then save file using press Esc type :wq then press Enter.
Step #04: Create tomcat start and stop file.
[email protected]:~# vim /etc/init.d/tomcat
Then insert below all text into tomcat file.
#!/bin/bash
### BEGIN INIT INFO
# Provides:tomcat8
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop Tomcat server
### END INIT INFO
JAVA_HOME=/home/app/Java/jdk/8.0.191
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/home/app/Tomcat/8.0.53
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
For save press Esc type :wq then press Enter.
Step #05: Setup permission for tomcat file.
[email protected]:~# chmod 755 /etc/init.d/tomcat [email protected]:~# /etc/init.d/tomcat start
all is done! now browse your server ip address using 8080 port.
http://10.66.50.10:8080
If any problem please see my YouTube channel for more details. Please subscribe my channel for more update.
- How To Install Odoo 16 on Ubuntu 22.04 - May 14, 2023
- 12 Steps to Organize Photos on Your Computer - March 20, 2023
- 9 Ways to Speed Up Your MacBook Yosemite - February 21, 2023
We really appreciate for your support for buying me a coffee.
It takes us a while to compose and upload new content, as they have to be checked to see if Properly works. We appreciate you if you help me for one cup of coffee to keep us awake and always deliver good quality content.
No contribution is small of an amount. We are grateful for any amount you support us with. Thank you!