Deploy Java .jar to Digital Ocean VPS?

Hi, I already have a Digital Ocean VPS that is hosting my static html portfolio website. I am making a REST API in Java (spring boot) and I will have an executable .jar. I want to deploy this on my VPS.

Can I create another Virtual Host in my /var/www directory, so I will have 2 Virtual Hosts on the same VPS?

Also, is running the Java .jar on the VPS as easy as FTPing the .jar over to the server, then simply running it as a service, i.e. systemctl start myjar?

Or are there more steps needed ? When I disconnect from ssh to my VPS, will the jar continue running? It’s an API with endpoints so its needs to be up 100% of time.

Thank you.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

OK , I figured this all out after 1 week of research.

So the first step is getting the server setup, for most Spring boot apps, this means installing Java on the server and some type of Database, I choose PostgreSQL.

  1. Install Java
  2. Install PostgreSQL (or your database choice)

Make sure to create the user and database that you will use for your connection string in your (or where ever your connection info is) or you won’t be able to connect to your Database and your app won’t run

Then you can build up your Spring boot application locally and package it into a FAT(executable) .jar file. Make sure you have the spring-boot-maven-plugin for that

  1. Then you can run in the terminal
./mvnw clean package -Dmaven.test.skip=true

Make sure your database credentials are inside your file or whatever file they need to be in before you package your code into a jar

  1. SCP your jar file to your Digital ocean. A director like /var/myapp works good.

You should have the Apache Web Server already installed and setup for a non-root user. Digital ocean has alot of good guides to set that up.

You can run your jar by typing:

java -jar yourjarfilename.jar

It should spin up and start successfully.

If you’re using a Spring Boot app that uses the embedded Tomcat server like me, since the Apache Web Server listens for HTTP on port 80, and the Tomcat default port is 8080, no traffic will be sent to your Tomcat server.

Thus , you will need to setup a reverse proxy so your Apache web server re-routes HTTP traffic to your embedded Tomcat listening on port 8080.

Because I still wanted to use my frontend static website located at, that means I had to make the ProxyPass redirect at the which a /api route, or else it rerouted all my traffic and I was never able to access the root of my website at This could be want you want though, if you plan to have your main Spring boot/Tomcat server as your main application

You can then setup your Spring boot app as a Systemd service so that its managed by Systemd and runs even when you close out the SSH connection and logs to journalctl Read about that here

Good luck!