Install and deploy
- How to deploy a WAR file to Tomcat
Step by step: deploy a WAR file to Tomcat on Ubuntu, serve it at the root context, restart safely, read the logs and roll back. Covers Tomcat 9, 10 and 11.
- Run a Spring Boot JAR as a systemd service
Run a Spring Boot executable JAR as a systemd service: unit file, unprivileged user, environment file, restart policy, JVM options and zero-surprise deploys.
- Nginx reverse proxy for a Java application
Put Nginx in front of Tomcat or Spring Boot: server block, forwarded headers, WebSockets, upload limits and Let's Encrypt certificates with certbot.
- Install Apache Tomcat on Ubuntu
Install Tomcat 10.1 on an Ubuntu VPS with OpenJDK 21, a systemd service, a memory limit and Nginx in front. Commands you can copy.
- Install WildFly on Ubuntu
Install the latest WildFly on an Ubuntu VPS with Java 21: dedicated user, systemd unit, proxy settings, a root-context WAR and a sensible heap.
- Install Payara Server on Ubuntu
Install Payara Server (Jakarta EE 11) on an Ubuntu VPS: download, dedicated user, heap settings in domain.xml, systemd unit and WAR deployment.
- Deploy a Spring Boot application to a VPS
The full path from a fresh Ubuntu VPS to a Spring Boot app on your domain with HTTPS: Java, a service user, systemd, Nginx, Let's Encrypt and a firewall.
- Deploy a Quarkus application to a VPS
Run a Quarkus app on an Ubuntu VPS in JVM mode: package, copy the fast-jar, systemd service, memory settings and Nginx. Notes on native builds.
- Run a Java application with Docker Compose on a VPS
Install Docker on Ubuntu, write a Dockerfile and Compose file for a Java app with PostgreSQL, set memory limits for the JVM and update with one command.
- Install Java 21 on Ubuntu
Install OpenJDK 21, 17, 11 or 8 on Ubuntu with apt, switch between versions with update-alternatives and set JAVA_HOME correctly.
- Connect Tomcat to PostgreSQL or MySQL
Install a database on the same VPS, create a user, add the JDBC driver and configure a pooled JNDI DataSource in Tomcat. Settings for small servers.
- How to install Tomcat on Debian or Rocky Linux
Install Java and Apache Tomcat from the distribution packages on Debian, Rocky Linux and AlmaLinux, start it with systemd and open the firewall port.
- Tomcat memory settings: where to put -Xmx
Where to set -Xmx and other JVM options for Tomcat: /etc/default/tomcat10, setenv.sh or a systemd drop-in, and how to confirm the setting took effect.
- How to run Tomcat on port 80 and 443
Linux does not let normal users open ports below 1024. Three ways to serve Tomcat on port 80 and 443: reverse proxy, systemd capability, or firewall redirect.
- Tomcat behind Nginx: HTTPS and real client IP
Fix redirect loops, http links and wrong client IP when Tomcat runs behind Nginx. Set the proxy headers and the RemoteIpValve in server.xml.
- How to host multiple domains on one Tomcat
Run several websites from one Tomcat with a Host element per domain, one ROOT application each, plus Nginx to route and secure every domain.
Memory and performance
- How much RAM does a Java application need?
How to size memory for a Java app: heap, metaspace, threads and native memory, with typical numbers per server type and the VPS size that fits.
- JVM heap settings explained: Xmx, Xms and friends
How to set the JVM heap on a server: -Xmx, -Xms, MaxRAMPercentage, garbage collector choice, metaspace and what to do on out-of-memory errors.
- How to fix a Java OutOfMemoryError
Find out which OutOfMemoryError you have, read the message, take a heap dump and fix it. Also what to do when Linux kills Java without any error.
- Choose a Java garbage collector for a small server
How to pick a garbage collector for a 1 to 16 GB Java VPS: Serial, Parallel, G1 and ZGC compared with the flags and when each makes sense.
- Add swap to a Java server
Create a swap file on Ubuntu, set swappiness for a JVM workload and understand when swap protects a small server and when it just hides a memory problem.
- Take a thread dump and a heap dump
Diagnose a hung or slow Java application: take thread dumps with jcmd and jstack, read blocked threads, capture a heap dump and copy it off the server safely.
Operations and security
- Harden a Java VPS
A practical security checklist for a Java server on Ubuntu: SSH keys only, UFW, Fail2ban, unattended upgrades, localhost-only app ports and safe admin consoles.
- Back up a Java VPS with restic
Daily encrypted backups of your application and database to S3-compatible storage or SFTP with restic, retention rules, a systemd timer and a restore test.
- Monitor a Java VPS
What to watch on a Java server and how to do it cheaply: external uptime checks, Spring Boot Actuator, JVM metrics, disk and memory alerts and failed-service notifications.
- Java VPS go-live checklist
A short checklist before you put a Java application on a VPS in production: memory, HTTPS, firewall, restarts, logs, backups, monitoring and updates.
Troubleshooting
- How to fix Tomcat 503 Service Unavailable
A 503 means Tomcat is up but the application is not. Find the cause in the logs: failed startup, wrong Java version, missing dependency or memory.
- How to fix a Tomcat 404 after deploying a WAR
Why you get HTTP 404 after deploying a WAR to Tomcat: wrong context path, failed deployment, permissions, jakarta namespace or a missing ROOT application.
- How to fix "Address already in use" on port 8080
Find which process owns port 8080 with ss or lsof, stop it, or move your Java application to another port. Works for Tomcat and Spring Boot.
- How to fix Tomcat Manager 403 Access Denied
Tomcat Manager returns 403 from a remote address by design. Reach it through an SSH tunnel, add a user with the right role and keep it off the internet.
- How to fix OutOfMemoryError: Metaspace
Metaspace holds class metadata. Learn why it fills up after redeploys, how to cap it with MaxMetaspaceSize and how to find a classloader leak.
- Why Linux kills your Java process, and how to stop it
Your Java service disappears with no error in its own log. Confirm the Linux OOM killer in dmesg, then lower the heap, add swap, limit memory with systemd.
- Java app slow or using high CPU on a VPS
A step-by-step check for a slow Java application: CPU steal, swapping, garbage collection, a busy thread and slow database queries, with commands.
- How to fix UnsupportedClassVersionError
Your server runs an older Java than the one that built the application. Map the class file number to a Java version and switch Java for Tomcat or systemd.
Choose and migrate
- Tomcat vs WildFly vs Payara vs Spring Boot
Compare Tomcat, WildFly, Payara and Spring Boot: what each is, memory use, Jakarta EE support, deployment style and which one fits your project.
- Shared Java hosting vs a Java VPS
Shared Java hosting or a Java VPS? Compare memory limits, Java versions, isolation, control and cost, and see when each makes sense.
- How to move a Java application from cPanel to a VPS
Moving a Java or Tomcat application from cPanel or shared hosting to a VPS: inventory, sizing, database export, deployment, DNS cutover and a rollback plan.
- Java LTS versions: which one to run on your server
Java long-term support versions compared: 8, 11, 17, 21 and 25. What changed, what each framework requires and which version to choose for a server.
- Migrate from Tomcat 9 to Tomcat 10.1
Why applications break when moving from Tomcat 9 to 10, what changes from javax to jakarta, how to migrate with the Tomcat migration tool or by code, and how to test.
- Standalone Tomcat or Spring Boot embedded Tomcat?
Compare deploying a WAR to a standalone Tomcat with running a Spring Boot executable JAR: memory use, upgrades, several apps, operations and when each fits.
- How much does Java hosting cost?
What you pay for in Java hosting: RAM above all, then CPU, backups, support and your own time. How to size a plan and compare offers fairly.
Tools
- JVM heap size calculator
Free calculator: enter your server RAM, database and app server and get -Xmx, -Xms, metaspace and database buffer sizes, ready to paste into systemd.