Here's a newer way to install Java JDKs and, if you must, Tomcat. Use SDKMAN.io. Root access is not needed since, by default, SDKMAN installs JDKs and SDKs in your home directory. You can install multiple versions or providers of JDKs and switch between them for different Java apps.
After completing the SDKMAN install steps, you can begin using SDKMAN to install JDKs and SDKs:
sdk install java 25.0.4-tem
sdk install tomcat
FYI, I'm investigating Java again after a long hiatus. It's a multi-billion dollar ecosystem paid for by the Enterprise guys and available to us peasants for free. It can be ridiculously fast compared to PHP or Python with similar memory footprints. For much lighter weight, lower memory, use Quarkus.io, not Spring Boot. If you need even lower memory footprints, Quarkus apps can be compiled with GraalVM into native Linux binaries. The Enterprise guys have spent many $millions on Quarkus to squeeze their apps into lower memory Kubernetes containers. The results of this also works well on hosting like Opalstack.