Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk11 min

How to Run a JAR File on a Linux VPS

A practical, production-ready walkthrough for running a Spring Boot, Ktor, or other Java JAR on a Linux VPS with OpenJDK, systemd, secure permissions, firewall checks, and journal-based troubleshooting.

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.

The reliable production method is to run the JAR as a systemd service under a dedicated, unprivileged account. First install the Java runtime your application requires, upload the artifact, run a manual smoke test, then create and enable a service so it starts after reboot, restarts after failures, and writes logs to the journal. A direct java -jar command is useful for testing, but a process attached to an SSH shell is not a durable service.

What you need before deployment

Have these details ready before connecting to the VPS:

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.
  • An SSH hostname or IP address, a login account, and the authentication method (key or password) accepted by the server.
  • The Java release required by the JAR. A JAR built for a newer Java release will not run on an older runtime, and framework requirements may impose additional constraints.
  • The local path to the built artifact, such as build/libs/app.jar.
  • The port on which the application listens and whether it should bind to loopback only or to a public interface.
  • Every required environment variable, secret, database connection, and external service address.
  • Access to both the VPS provider’s network firewall and the Linux host firewall, if either is enabled.

Use a predictable application path, such as /opt/myapp, so service files, release procedures, permissions, and troubleshooting all refer to the same locations.

Choose how the JAR should run

The command itself is simple, but the way it is supervised determines whether the application survives logout, reboot, and a crash.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
Approach After SSH logout After reboot Restart policy Logs Best use
Direct java -jar in SSH Stops when the shell closes Does not start Manual Current terminal First-run smoke test
screen or tmux Session can remain available Does not start unless recreated Manual Terminal/session Temporary debugging
systemd service Continues independently Starts when enabled Declarative, such as restart on failure journald Standard single-VPS production deployment
Container or orchestrator Depends on the runtime Depends on the runtime configuration Runtime-specific Runtime-specific Multi-service or repeatable infrastructure

For one Spring Boot, Ktor, or similar JVM application on a Linux VPS, use the systemd path below. Keep screen or tmux for diagnosing a problem before the service exists, not as the permanent supervisor.

1. Connect over SSH and check the server

Connect with the account that will perform deployment. Replace the placeholder host and user with your values:

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

Confirm that the account can use sudo for package installation and service administration. Also identify which firewalls apply. A provider-level rule can block traffic before it reaches the VPS, while the operating-system firewall can block it after it arrives. You may need to change both later.

Do not expose the application publicly just because the process starts. Test it on loopback first and open only the ports required by your architecture.

2. Install a compatible Java runtime

Install the runtime that matches the release used to build the JAR. On Debian or Ubuntu, a headless OpenJDK package is normally sufficient for a server process because it omits desktop components. The following example installs Java 17:

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

Package names and available versions differ by distribution. If the application requires another release, select the corresponding package instead of copying the Java 17 example. Verify the result:

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

Compare the reported major version with the application’s build configuration and framework requirements. If the manual launch later reports an unsupported class-file version, the runtime is too old for the JAR. If multiple Java installations are present, find the executable that the service should use:

which java
readlink -f $(which java)

Use the resulting absolute path in the service unit. An interactive shell and systemd can have different PATH values, so relying on a bare java command in ExecStart can make a service fail even when it worked interactively.

3. Create a dedicated application account and directory

Do not run a network-facing Java application as root. A dedicated account limits the files and system actions available if the application or one of its dependencies is compromised.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Create a system account and an application directory. The exact account-management flags vary slightly by distribution; this example uses common Debian and Ubuntu syntax:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo useradd --system --home /opt/myapp --shell /usr/sbin/nologin myapp
sudo mkdir -p /opt/myapp
sudo chown -R myapp:myapp /opt/myapp

If the account already exists, do not recreate it; ensure it owns the directories and files it must read or write. Grant access only where required. The service generally needs read access to the JAR and configuration, plus write access to specific upload, cache, temporary, or log directories if the application uses them. Avoid making the entire filesystem or broad shared directories writable.

Keep secrets separate from the JAR. A plain environment file is convenient, but it must be readable only by the service account or by root as appropriate for your operating model. Never put credentials in a world-readable directory or commit them to the application repository.

4. Upload the JAR

From your local computer, copy the artifact to the application directory. For example:

scp build/libs/app.jar user@your_server:/opt/myapp/app.jar

The upload account must be able to write the destination. If you copied as an administrative user, fix ownership before starting the service:

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.
sudo chown myapp:myapp /opt/myapp/app.jar
sudo chmod 0644 /opt/myapp/app.jar

Keep release files in a predictable layout. A single stable path such as /opt/myapp/app.jar makes the service unit simple. If you retain several versions for rollback, place them in a controlled releases directory and update the stable path deliberately; do not leave the service pointing at a file that disappears during deployment.

Make configuration explicit. For non-secret settings, document the expected names and values. For secrets and environment-specific values, create an environment file, for example:

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

Edit that file with the variables your application expects. Do not assume that variables available in your interactive shell will be present in a systemd service.

5. Run a manual smoke test

Before adding supervision, prove that the artifact, runtime, working directory, configuration, and port are correct. Run the JAR as the service account:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
sudo -u myapp /usr/bin/java -jar /opt/myapp/app.jar

Use the absolute Java path you verified earlier. Watch the startup output for a successful framework initialization, database connection errors, missing secrets, bind failures, or an incompatible Java version. Leave this command running while you test it from another SSH session, or stop it with Ctrl+C after the check.

Test a local endpoint from the VPS itself:

curl http://127.0.0.1:<port>/

Replace <port> with the configured application port. A successful loopback response proves that the process is listening locally; it does not prove that provider or host firewall rules permit public traffic. If the endpoint fails, fix the application first rather than creating a service around a broken launch.

6. Create a systemd unit

Create /etc/systemd/system/myapp.service with a unit similar to this:

[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

Write the file with administrative privileges, then check each value:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Description: A label shown by status and journal tools.
  • After=network.target: Orders service startup after the basic network target. It does not guarantee that every remote dependency is ready; the application should handle dependency retries where necessary.
  • User: Runs the JVM as myapp, not root.
  • WorkingDirectory: Sets the process directory for relative paths used by the application.
  • ExecStart: Uses absolute paths for both Java and the JAR. Replace them if your installation or filename differs.
  • Restart=on-failure: Requests a restart when the process exits unsuccessfully. It does not fix a bad configuration; a repeatedly failing process will still require investigation.
  • RestartSec=5: Waits five seconds between failed starts, preventing an immediate tight restart loop.
  • EnvironmentFile: Loads variables from the specified file. Keep that file protected and ensure its syntax matches systemd environment-file rules.
  • StandardOutput and StandardError: Send normal output and errors to the journal, where they can be followed with journalctl.
  • WantedBy=multi-user.target: Defines the boot target used when the service is enabled.

Do not copy arbitrary heap settings into ExecStart. JVM memory flags must fit the VPS’s available RAM and the application’s workload. An oversized heap can cause the operating system to reclaim memory or kill the process; an undersized heap can cause out-of-memory failures. Start without custom flags unless the application’s documented requirements call for them, then size deliberately.

Protect the unit and environment file with normal administrative permissions. The JAR can be readable by the service account, while secrets should have the narrowest practical read access.

7. Load, enable, and start the service

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

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 in the current session. start launches it immediately. You can combine those actions with sudo systemctl enable --now myapp after the unit has been verified.

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

A healthy status normally shows an active running process and the command line you expect. If it is inactive or repeatedly restarting, inspect the journal before changing settings.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

8. Read logs and diagnose failures

Follow the service’s live logs:

sudo journalctl -u myapp -f

For a bounded view of recent startup output:

sudo journalctl -u myapp -n 100 --no-pager
sudo systemctl status myapp

Use the symptom to narrow the cause:

The service cannot find Java or the JAR

Check the absolute path in ExecStart, verify the file exists, and inspect ownership and permissions:

ls -l /usr/bin/java /opt/myapp/app.jar
sudo -u myapp test -r /opt/myapp/app.jar && echo readable

A path that worked in your shell may fail under systemd because the service has a different working directory or environment.

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

The application exits with an incompatible Java error

Run java -version using the same executable named in ExecStart. Install the Java release required by the build and framework, then restart the service. Do not solve a version mismatch by changing unrelated service settings.

A required variable or secret is missing

Confirm the variable is present in /opt/myapp/app.env, that the file is readable by myapp, and that its spelling matches the application configuration. Reload the unit after changing the file, then restart:

sudo systemctl daemon-reload
sudo systemctl restart myapp

The working directory or relative file path is wrong

Check WorkingDirectory and convert fragile relative paths to explicit paths where practical. Ensure any upload, cache, or temporary directory exists and is writable by myapp.

The port is already in use

Find the process holding the configured port, stop the conflicting service, or change the Java application’s port intentionally. A second copy of the same JAR is a common cause after a manual smoke test was left running:

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

Stop the manually launched process before starting the managed service.

The process restarts repeatedly

Read the complete journal output rather than treating the restart as the root cause. Common underlying causes include a bad path, incompatible Java version, missing secret, port collision, invalid configuration, or insufficient memory. Fix the underlying error, then start the service again and verify one clean boot.

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

9. Make the application reachable safely

Keep the first test on 127.0.0.1. Once the application is healthy, decide how it should be exposed.

Direct application port

If clients must connect directly, bind the application to the required interface and open that port in both layers that control traffic: the VPS provider’s network rules and the host operating-system firewall. Opening only one layer is insufficient. Limit source addresses where possible instead of exposing an administrative or internal port to the entire internet.

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

Reverse proxy for public web traffic

For an HTTP application, a reverse proxy such as Nginx can accept public traffic, terminate TLS, and forward requests to the Java process on a private local port. This keeps the JAR’s listener separate from certificate handling and lets you expose only the proxy’s web ports. The exact proxy configuration depends on your domain, TLS setup, headers, WebSocket needs, and application port; test the local upstream first and then verify the public route.

The application must listen on an address reachable by the proxy. If it binds only to loopback, a proxy on the same VPS can reach it; if the proxy is on another host, the bind address and firewall policy must allow that connection. Never open more interfaces than the architecture requires.

10. Updating the JAR without losing control

Use a controlled sequence for a new build:

  1. Build and verify the artifact locally.
  2. Upload it to a temporary or versioned path rather than overwriting a file while the JVM is reading it.
  3. Stop the service with sudo systemctl stop myapp.
  4. Place the new artifact at the path referenced by ExecStart and restore ownership for myapp.
  5. Start the service and immediately inspect sudo systemctl status myapp and sudo journalctl -u myapp -n 100 --no-pager.
  6. Run a loopback curl check against the expected endpoint.

Retain the previous known-good artifact until the new one has passed its startup and endpoint checks. If the new release fails, stop it, restore the previous file, start the service, and inspect the journal for the release-specific error.

If you change only the environment file, a daemon reload is not usually needed for the file itself, but the process must be restarted to receive new values. If you change the unit file, run sudo systemctl daemon-reload before restarting.

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

11. Verify reboot behavior

Do not assume that an enabled service works at boot because it started manually. After saving the unit and confirming a clean run, schedule a maintenance window and reboot:

sudo reboot

Reconnect over SSH, then check:

sudo systemctl status myapp
sudo journalctl -u myapp -b --no-pager
curl http://127.0.0.1:<port>/

The -b option limits journal output to the current boot. This check catches missing boot-time environment variables, incorrect filesystem paths, startup ordering assumptions, and services that were accidentally launched only from an interactive shell.

Common deployment mistakes to avoid

  • Closing SSH after a direct launch: the shell-owned process stops, so use systemd for persistence.
  • Running as root: create a dedicated account and grant only the access the application needs.
  • Installing the wrong Java release: match the runtime to the JAR’s build and framework requirements.
  • Using relative paths: set WorkingDirectory and prefer explicit locations in service configuration.
  • Assuming shell variables carry over: list required values in a protected EnvironmentFile.
  • Opening a firewall port before local testing: prove the process works on loopback, then expose only the necessary route.
  • Forgetting provider-level rules: both the VPS network controls and host firewall can affect reachability.
  • Copying arbitrary JVM heap flags: size memory for the actual VPS instead of applying values from another machine.
  • Leaving a smoke-test process running: stop the manual JVM before starting the managed unit to avoid a port collision.
  • Ignoring the journal: status shows the unit state, while journalctl -u myapp -f usually reveals the application error.

Operational checklist

  • SSH login works for the deployment account and that account has the required administrative access.
  • The installed headless OpenJDK major version matches the JAR and framework.
  • /opt/myapp and the artifact are owned and readable by the dedicated service account.
  • The manual java -jar launch completes startup and responds to a loopback curl request.
  • The unit uses absolute paths, a correct working directory, the intended user, and a protected environment file.
  • systemctl enable and systemctl start complete without a restart loop.
  • Journal output is available and free of unresolved startup errors.
  • Provider and host firewall rules expose only the required ports.
  • A reboot test confirms automatic startup and local health.

The Bottom Line

For a Linux VPS, use java -jar only to validate the artifact. Run the application in production as a dedicated non-root systemd service, verify it locally, then expose it through the minimum firewall and reverse-proxy path your architecture needs.

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.

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

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 from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.