Requirements
You will need to know the path to the base Java folder (the path without /bin/java at the end) to provide it as the JAVA_HOME environment variable in the management service. The specific path to Java will vary depending on the platform, OS version, OpenJDK vs. Oracle JDK, etc.
Following are different methods that you can use to find the path to Java on your system:
Reference the JAVA_HOME environment variable:
$ echo $JAVA_HOME
/usr/lib/jvm/java-21-openjdk-amd64
Use update-alternatives:
$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-21-openjdk-amd64/bin/java
Nothing to configure.
Use whereis to find "java" and follow the breadcrumbs:
$ whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz
$ ls -al /usr/bin | grep java$
lrwxrwxrwx 1 root root 22 Jul 18 09:35 java -> /etc/alternatives/java
$ ls -al /etc/alternatives | grep java$
lrwxrwxrwx 1 root root 43 Jul 18 09:35 java -> /usr/lib/jvm/java-21-openjdk-amd64/bin/java
- Using your preferred text editor, create a tomcat systemd service file with a command similar to
sudo vi /etc/systemd/system/tomcat.service
- Paste the following into the
tomcat.service file:[Unit]
Description=Jamf Pro Web Application Container
Wants=network.target
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
- Ensure the
JAVA_HOME value in the tomcat.service file matches the path to the JDK installed on the system, not including /bin/java at the end (see above for guidance on finding this path). - Save the tomcat.service file.
- Restart the systemd daemon by executing:
sudo systemctl daemon-reload
- Start the Tomcat service by executing:
sudo systemctl start tomcat
- To check the status of Tomcat, execute:
Note:You need to press the Q key to exit from the status reporting.
- Enable auto startup of the Tomcat service at boot by executing:
sudo systemctl enable tomcat