As the title described, in Ubuntu 20.04 how to set Tomcat 9 to use Java 17 ?
Recently I repacked the war file of my web project with Spring Boot 3.0.1 which requires Java 17 to run, trying to deploy it to Tomcat 9 container at an Ubuntu 20.04 server.
It seems that the best way is to utilize the setenv.sh
.
I've followed some documents,
created a folder bin
in /usr/share/tomcat9
, touched file of setenv.sh
,
edited its content with JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
.
Then run sudo systemctl start tomcat9
, but failed.
sudo systemctl status tomcat9
said "No JDK or JRE found - Please set the JAVA_HOME variable or install the default-jdk package",
Installed openjdk-17-jre-headless, and removed openjdk-11-jre-headless at first. Both Tomcat9 and JRE 17 is installed by apt package manager.