October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Run a JAR File on a Linux VPS

Learn how to deploy a Spring Boot, Ktor, or other Java JAR on a Linux VPS using a compatible OpenJDK runtime, a dedicated service account, systemd, journal logs, and safe network configuration.
Length10 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable way to run a Java archive on a Linux VPS is to install the JRE version the application needs, place the JAR in a controlled directory, test it locally, and run it as a dedicated systemd service. A one-off java -jar command is useful for a smoke test, but it is tied to your SSH session and will not provide boot startup, automatic recovery, or persistent logs.

This guide covers Ubuntu and Debian-style servers, including Spring Boot and Ktor applications. Replace package names, paths, usernames, ports, and environment variables with the values required by your application.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you need before deploying

Have these details ready before connecting to the VPS:

  • SSH access to an account that can use sudo.
  • The Java release used to build the application and any framework requirement. A JAR compiled for a newer release will not run on an older runtime.
  • The JAR file, its listening port, and any required configuration such as database URLs, API keys, or active profiles.
  • The VPS provider’s network controls and the host operating system’s firewall settings.
  • A health or ordinary HTTP endpoint that you can test locally after startup.

Use a dedicated application directory such as /opt/myapp. Keeping code, configuration, and logs in predictable locations makes upgrades and incident recovery easier.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

1. Connect over SSH and identify the operating system

Connect with the account that will perform the deployment:

ssh your_user@your_server

On a Debian or Ubuntu VPS, confirm the distribution and available package manager before installing Java:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cat /etc/os-release
uname -m

Do not assume that a package name from Ubuntu applies unchanged to another distribution. The service design below works on most modern Linux distributions, but Java package names, firewall commands, and the default Java path can differ.

2. Install a compatible Java runtime

Install the headless OpenJDK package that matches the application’s required Java release. For an application requiring Java 17 on Debian or Ubuntu, the documented package sequence is:

sudo apt update
sudo apt install openjdk-17-jre-headless -y

Verify the runtime and the executable location:

java -version
command -v java
readlink -f $(command -v java)

The output of java -version must be compatible with the JAR. If the application was built for a later release, install that release instead of forcing it to run on Java 17. If several Java versions are installed, select the intended default with your distribution’s alternatives mechanism, or use the absolute path to the desired binary in the service file.

A common failure is an error such as an unsupported class-file version. That means the runtime is older than the JDK used to build the application. Install the required release, verify it as the same user that will run the service, and test again.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Create an unprivileged service account and application directory

Do not run a network-facing Java process as root. A dedicated account limits what an exploited application can read or modify. The account normally needs no interactive shell and should own only the files it must use.

sudo useradd --system --home /opt/myapp --shell /usr/sbin/nologin myapp
sudo install -d -o myapp -g myapp /opt/myapp
sudo install -d -o myapp -g myapp /opt/myapp/releases

If your distribution already has a service-account convention, follow it. The important properties are that the account is separate from your login account, has no unnecessary administrative privileges, and can read the JAR and its configuration.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

4. Upload the JAR and make configuration explicit

From your local computer, upload the artifact with SCP. The following example uses a build output directory and a temporary filename:

scp build/libs/app.jar your_user@your_server:/tmp/app.jar

On the VPS, install it into the application directory and assign ownership:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo install -o myapp -g myapp -m 0644 /tmp/app.jar /opt/myapp/app.jar
sudo rm /tmp/app.jar

Keeping the file at a stable path lets the service unit remain unchanged when you replace a release. For rollback-friendly deployments, store versioned files under /opt/myapp/releases and make /opt/myapp/app.jar a controlled symlink; if you use that arrangement, ensure the service account can traverse every parent directory.

Environment files and secrets

Put settings that vary by server outside the JAR. Create an environment file readable only by the service account:

sudo install -o myapp -g myapp -m 0600 /dev/null /opt/myapp/app.env
sudoedit /opt/myapp/app.env

Use the variable names expected by your framework and application. Do not commit passwords or API keys to the JAR repository, place them in shell history, or make the environment file world-readable. The service unit later loads this file with EnvironmentFile=/opt/myapp/app.env.

5. Run a manual smoke test

Before creating a background service, start the application once in the SSH session. Running it interactively exposes dependency, port, and configuration errors immediately:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo -u myapp /usr/bin/java -jar /opt/myapp/app.jar

Watch the startup output for a successful initialization message and the actual bound port. In a second SSH session, test the application through the loopback interface:

curl -i http://127.0.0.1:8080/

Replace 8080 and the path with your application’s values. A Spring Boot application may expose a health endpoint only when its actuator settings enable one; a Ktor application may use a route defined by the project. A successful local response proves that the process is listening on the VPS, but it does not yet prove that external firewall rules or public DNS are correct.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Stop the foreground process with Ctrl-C after the smoke test. Do not leave an SSH-owned process as the production arrangement.

6. Create a systemd unit

Create /etc/systemd/system/myapp.service with an absolute Java path and the real account and directories:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[Unit]
Description=My Java application
After=network.target

[Service]
Type=simple
User=myapp
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/java -jar /opt/myapp/app.jar
Restart=on-failure
RestartSec=5
EnvironmentFile=/opt/myapp/app.env
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

Edit the unit as an administrator:

sudoedit /etc/systemd/system/myapp.service

What the important directives do

  • User=myapp prevents the process from running with root privileges.
  • WorkingDirectory determines the process’s current directory, which matters when an application uses relative paths.
  • ExecStart uses an absolute Java path and an absolute JAR path, avoiding differences between an interactive shell and systemd’s environment.
  • Restart=on-failure asks systemd to restart an unexpectedly terminated process, while RestartSec=5 inserts a five-second delay.
  • EnvironmentFile loads server-specific settings without embedding secrets in the unit. Create the file before starting the service; otherwise startup can fail.
  • StandardOutput and StandardError send application output to the system journal.
  • WantedBy=multi-user.target allows the service to be enabled for normal multi-user boot.

Do not copy arbitrary heap limits into ExecStart. JVM memory options must leave room for the operating system and other processes on your VPS. Add flags only after you understand the application’s memory behavior and the server’s available RAM.

7. Load, enable, and start the service

Tell systemd about the new unit, configure boot startup, and launch it:

sudo systemctl daemon-reload
sudo systemctl enable myapp
sudo systemctl start myapp
sudo systemctl status myapp

enable creates the boot-time relationship; it does not start the process during the current session. start launches it now. If you want both actions in one command after a later edit, use sudo systemctl enable --now myapp.

The status view should show active (running). Check the listening socket from the VPS:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -i http://127.0.0.1:8080/
ss -ltnp | grep 8080

The second command is only a diagnostic; adjust the port and use the tool available on your distribution.

8. Read logs and diagnose failed starts

Follow the service’s journal while reproducing a problem:

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
sudo journalctl -u myapp -f

Useful one-time views include:

sudo systemctl status myapp --no-pager
sudo journalctl -u myapp -b --no-pager
sudo journalctl -u myapp -n 200 --no-pager

Check these items in order when the unit exits or repeatedly restarts:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Symptom Likely checks Correction
status=203/EXEC or Java not found The path in ExecStart and the result of command -v java Use the actual absolute Java path and run daemon-reload.
Permission denied Ownership and mode of the JAR, environment file, and every parent directory Grant myapp only the read or write access it needs.
Unsupported class-file version The JAR’s build release versus java -version Install and select a compatible Java runtime.
Immediate restart loop Missing variables, invalid configuration, bad working directory, or application stack trace Read the journal, correct the first application error, then restart.
Address already in use Another process listening on the configured port Stop the conflicting process or change the application’s port.
Process killed under load Available RAM and kernel or VPS memory events Reduce workload, allocate an appropriately sized VPS, or tune JVM settings conservatively.
Local curl works but remote requests fail Bind address, provider firewall, host firewall, DNS, and proxy configuration Resolve network reachability one layer at a time.

After changing a unit file, always run sudo systemctl daemon-reload. After changing the JAR or environment file, restart with sudo systemctl restart myapp and then inspect status and logs again.

9. Make the application reachable safely

Test loopback first

Start with 127.0.0.1. This separates application startup from network exposure and avoids opening a port before the service is known to work.

Check the bind address

An application bound only to 127.0.0.1 accepts requests from the VPS itself. An application intended to receive traffic directly from the network must bind to an appropriate interface, but exposing a raw application port is not always the best public architecture. Follow the framework’s configuration rules rather than assuming that changing the bind address is harmless.

Open both firewall layers when necessary

Many VPS providers have a network firewall outside the machine, while Linux may also run a host firewall. A port must be permitted in the provider controls and on the host when both are enabled. Open only the port and source ranges required by your design; leave administrative ports restricted to trusted networks where possible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a reverse proxy for public web traffic

For a public HTTP or HTTPS application, a reverse proxy such as Nginx can accept web traffic, terminate TLS, and forward requests to the Java process on a private local port. This keeps the application port off the public internet and centralizes web-server concerns. The exact proxy configuration depends on your domain, certificate method, headers, WebSocket needs, and application port, so validate those settings separately from the systemd deployment.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

10. Choose the right way to keep a JAR running

Several launch methods work in limited circumstances, but they do not provide the same durability or operations model:

Approach After SSH logout or reboot Restart policy Logs Best use
Direct java -jar in SSH Stops with the session; no boot startup Manual Current terminal First-run smoke test
screen or tmux Survives logout while the session exists; no automatic boot recovery by itself Manual Terminal session Temporary debugging or observation
systemd service Starts at boot when enabled Declarative restart policy journald Standard single-VPS production deployment
Container or orchestrator Depends on the runtime and its restart configuration Runtime-specific Runtime-specific Multi-service or repeatable infrastructure

Use screen or tmux when you need an interactive debugging session, not as a substitute for a service manager. A container can be appropriate when the rest of your infrastructure already uses one, but it adds another runtime and its own logging, storage, networking, and update rules.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

11. Update the JAR without losing control

A simple update sequence for a stable path is:

  1. Upload the new artifact to a temporary location rather than overwriting a running file.
  2. Validate its ownership, permissions, and Java compatibility.
  3. Stop or restart the service during your maintenance window.
  4. Install the new file as /opt/myapp/app.jar.
  5. Run sudo systemctl restart myapp.
  6. Check sudo systemctl status myapp, follow journalctl, and make a local curl request.

Versioned release directories make rollback clearer: keep the previous known-good JAR, point the stable path at the selected release, restart, and revert the path if the new process cannot pass its smoke test. Never delete the only working release before validating its replacement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

12. Spring Boot and Ktor deployment details

Spring Boot

Spring Boot commonly reads configuration from environment variables, command-line properties, or external configuration files. Confirm the active profile, database settings, server port, and any management endpoint before deployment. If a profile changes the listening port or context path, use those exact values in your local curl test and reverse-proxy configuration.

Ktor

Ktor applications can define the host and port in project configuration or environment variables. Verify the actual startup line rather than assuming a default. Test the route your application defines; a response of 404 can mean the process is healthy while the requested path is not registered.

For either framework, the JAR is only one part of the deployment. External services, writable upload directories, certificates, native libraries, and secrets must also be available with permissions appropriate to myapp.

13. Security and maintenance checklist

  • Run the application as a non-root account.
  • Keep the JAR and environment file owned by the service account, with the environment file restricted to that account.
  • Use an absolute Java path and verify the runtime after upgrades.
  • Keep credentials out of source control and shell history.
  • Bind privately when a reverse proxy is the intended public entry point.
  • Open only required provider and host firewall ports.
  • Review journal output for repeated crashes, authentication errors, and unexpected network activity.
  • Plan how to rotate secrets and replace the JAR without deleting the last known-good release.
  • Test a reboot before calling the deployment complete.

14. Verify automatic startup after a reboot

Once local requests and logs look correct, schedule or perform a controlled reboot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo reboot

Reconnect after the VPS returns and verify:

sudo systemctl is-enabled myapp
sudo systemctl status myapp
curl -i http://127.0.0.1:8080/

is-enabled confirms that boot startup is configured; status confirms the current process; the local request confirms that the application actually became ready. If the service is enabled but failed, inspect the boot-specific journal with sudo journalctl -u myapp -b and correct the first failure shown.

Final deployment checklist

  1. SSH access works and the VPS firewall plan is understood.
  2. The installed Java release matches the JAR’s build requirements.
  3. myapp owns only the files it needs and is not root.
  4. The artifact is in the expected directory and configuration is explicit.
  5. A foreground smoke test succeeded with a loopback curl request.
  6. The systemd unit uses valid paths, an existing environment file, and the correct port.
  7. The service is enabled, running, and writing useful journal entries.
  8. Provider and host firewall rules expose only the intended interfaces and ports.
  9. A reverse proxy and TLS are used when the application is serving public web traffic.
  10. A reboot test confirms that the service returns automatically.

With these pieces in place, the VPS treats the JAR as a managed Linux service rather than a process attached to one SSH window. You get controlled startup and shutdown, restart behavior, journal-based diagnostics, and a repeatable path for updates.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.