Your Java application is ready. You hit "Run" — and it crashes. Sound familiar? Don’t worry — you’ve got this! This guide will walk you through setting everything up right from the start. Whether you’re an experienced developer or just beginning, we’ll cover it all: choosing the right hosting, launching your app, and keeping it running smoothly. Let’s get started and make it work flawlessly!
Java applications come with unique needs that standard hosting plans often miss. We’ll show you how to pick the perfect server and deploy your app without the headaches.
Don’t settle for just any hosting — Java needs a thoughtful choice. Here’s what matters:
A solid host sets the stage for success.
Once you’ve chosen your hosting, it’s time to set up the server and bring your app to life.
Java powers your app, so install a current JDK version first. On Ubuntu, it’s simple:
sudo apt update
sudo apt install openjdk-21-jdk
Confirm it works:
java -version
Apache Tomcat is a great pick for Java. Install it on Ubuntu:
sudo apt install tomcat10
sudo systemctl start tomcat10
sudo systemctl enable tomcat10
Is Tomcat up? Visit < a href="http://your-server-ip:808">http://your-server-ip:8080. If you see Tomcat’s welcome page, you’re on the right track!
mvn clean packageYour WAR file will appear in /target/ as your-application.war.
scp your-application.war username@your-server-ip:/var/lib/tomcat10/webapps/
http://your-server-ip:8080/your-application
Change the Port: Not a fan of 8080? Edit server.xml
in Tomcat:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Nicer URL: Replace /your-application
with /myapp
by adding a context.xml
file to your WAR’s META-INF folder.
Add HTTPS: Enable HTTPS to secure user data. For more information, see the article ““How to switch to HTTPS and HTTP/2””.
/var/log/tomcat10/catalina.out.
Launching your Java app can be simple — let’s do it right! Set up your server properly, and it’ll run fast, stay stable, and handle whatever comes its way.