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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

The reliable way to run a Java JAR on a Linux VPS is to test it with java -jar, then run it as a dedicated systemd service. The service keeps the application running after SSH disconnects, starts it after a reboot, restarts it after failures, and sends output to the system journal.

What you need before deploying

You need SSH access to the VPS, a JAR built for a known Java release, and permission to install packages and create a service. The commands below assume Debian or Ubuntu. Other distributions use different package managers and may place Java in a different path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • The VPS must have enough CPU, memory, disk space, and network capacity for the application and its dependencies.
  • Know which Java release the JAR requires. A JAR compiled for a newer release will not run on an older runtime.
  • Know the port the application listens on and whether it should bind to loopback or a public interface.
  • Have any required database URL, API key, encryption key, profile, or other configuration ready. Do not hard-code secrets into a unit file that is readable by every user.
  • Know which account will own and run the application. A dedicated unprivileged account is safer than running Java as root.

Keep both layers of network filtering in mind: the VPS provider’s network firewall and the operating-system firewall inside the server. A process can be healthy locally and still be unreachable because one of those layers blocks its port.

Connect to the VPS and identify the Java requirement

Connect with the account that will perform the deployment:

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
ssh user@your_server

Check the operating system and any Java already installed:

cat /etc/os-release
java -version

The runtime must match the JAR’s build target and framework requirements. For example, a project documented for Java 17 should use a Java 17 runtime, not whichever version happens to be preinstalled. On Debian or Ubuntu, the headless runtime is usually sufficient for a server-side application because it omits desktop components.

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

Install a headless OpenJDK runtime on Ubuntu or Debian

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

Replace 17 with the release required by the application. Package names and available versions vary by distribution and repository. If several Java installations exist, locate the executable that the service should use:

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

Use the resulting absolute path in ExecStart rather than relying on a shell’s interactive PATH.

Create an application directory and a non-root service account

Keep the deployed files in a predictable location such as /opt/myapp. Create a system account with no interactive shell, then give it ownership of only the directories it needs:

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

If the account or directory already exists, do not create a second identity. Inspect it with id myapp and adjust ownership with sudo chown -R myapp:myapp /opt/myapp only after checking that the directory contains no unrelated files.

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.

Running as an unprivileged account limits what an exploited application can change. The account should have write access to application data, logs, or temporary directories only when the application genuinely requires it. It should not own system directories or receive broad sudo privileges.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Upload the JAR and make releases predictable

From your local computer, copy the artifact to the server. The following example uses the path shown in a typical Gradle build:

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

The remote account must be able to write to the destination. If /opt/myapp is owned by myapp and your SSH account is different, upload to a temporary location and install it with administrative privileges:

scp build/libs/app.jar user@your_server:/tmp/app.jar
ssh user@your_server 'sudo install -o myapp -g myapp -m 0755 /tmp/app.jar /opt/myapp/app.jar && rm /tmp/app.jar'

For repeatable updates, keep each release in its own directory and point a stable path such as /opt/myapp/current.jar at the selected artifact. A simpler single-file deployment is adequate for a small VPS, but retain a known-good copy before replacing it so that rollback is possible.

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

Run a manual smoke test before creating a service

Start the application in the SSH session first:

java -jar /opt/myapp/app.jar

Watch the startup output for the selected profile, database connection, migrations, bind address, and listening port. From another SSH session on the VPS, test a local endpoint:

curl http://127.0.0.1:<port>/

Replace <port> with the application’s configured port. A successful local response proves that Java can load the JAR and that the process is listening; it does not prove that external traffic can reach the VPS.

Stop the foreground process with Ctrl+C after the check. Running it directly in an SSH shell is not a production arrangement: the process normally ends when the shell or SSH connection closes, and it will not automatically return after a reboot.

Define a systemd service

Create a unit file at /etc/systemd/system/myapp.service:

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.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
[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

Use the absolute Java path returned by command -v java. Replace myapp, the working directory, JAR name, and environment-file path with your values.

What each important directive does

  • User=myapp prevents the process from running as root.
  • WorkingDirectory supplies the directory used for relative files and framework-generated paths.
  • ExecStart defines the exact command systemd launches. Do not use shell syntax unless you deliberately invoke a shell.
  • Restart=on-failure starts the process again when it exits unsuccessfully. RestartSec=5 prevents an immediate restart loop.
  • EnvironmentFile loads configuration without putting every value in the unit itself. The file must exist unless you mark it optional with a leading hyphen, and its syntax must match systemd’s environment-file rules.
  • StandardOutput and StandardError send normal output and errors to journald, where they can be followed with journalctl.
  • WantedBy=multi-user.target allows the unit to be enabled for normal multi-user boot.

Do not copy arbitrary JVM heap flags from another server. Memory settings must fit the VPS and leave room for the operating system and any sidecar processes. Add only flags you have chosen for this machine and application.

Store configuration and secrets separately

Create an environment file only if the application expects environment variables:

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

A file might contain entries such as:

SPRING_PROFILES_ACTIVE=production
SERVER_PORT=8080
DATABASE_URL=jdbc:postgresql://127.0.0.1:5432/app
API_TOKEN=replace-with-a-secret

Use the variable names documented by your framework or application. Keep the file readable only by the service account, verify that backups and deployment logs do not expose it, and never commit it to source control. If the application needs a certificate, upload it to a separately permissioned path and reference that path from the configuration.

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

Load, start, and enable the service

After saving the unit, ask systemd to reread its configuration and start the application:

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 a stopped service. start launches it now. You can combine both actions with sudo systemctl enable --now myapp after the first validation.

A healthy status normally shows active (running). Confirm the process is answering locally after systemd starts it:

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
curl http://127.0.0.1:<port>/

Use these controls for normal operations:

sudo systemctl restart myapp
sudo systemctl stop myapp
sudo systemctl start myapp
sudo systemctl disable myapp

Restarting applies a new JAR or changed environment file. Disabling prevents a future boot start; it does not necessarily stop a currently running process, so stop it separately when required.

Read logs and diagnose startup failures

Follow the service’s live journal:

sudo journalctl -u myapp -f

For a bounded investigation, inspect recent entries and the unit’s complete status:

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

Check these items in order when the service fails or repeatedly restarts:

  • Java path: confirm that the executable in ExecStart exists and runs with the selected account.
  • Java compatibility: compare java -version with the release used to build the JAR. An “unsupported class version” error means the runtime is too old.
  • File permissions: verify that myapp can read the JAR, environment file, certificates, and any writable data directory.
  • Working directory: ensure every relative path expected by the application exists under WorkingDirectory.
  • Environment variables: check spelling, quoting, required secrets, profile names, and the permissions on app.env.
  • Port collisions: use sudo ss -ltnp to find another process already listening on the configured port.
  • Memory: inspect the journal and system memory when the process is killed or exits during startup. Reduce unnecessary JVM allocations or move to a larger VPS if the workload genuinely needs more memory.
  • Application configuration: a failed database connection, migration, or external dependency can make a correctly installed service exit.

A restart loop is a symptom, not a diagnosis. Temporarily stop the unit, run the same command as the service account in the same working directory, and read the first meaningful exception rather than repeatedly restarting it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo systemctl stop myapp
sudo -u myapp sh -c 'cd /opt/myapp && /usr/bin/java -jar /opt/myapp/app.jar'

Stop that manual process with Ctrl+C before starting systemd again.

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

Make the application reachable safely

Keep the first test on loopback. An application bound to 127.0.0.1 accepts requests only from the VPS, which is appropriate when a reverse proxy on the same host will handle public traffic. Binding to 0.0.0.0 makes the process listen on all IPv4 interfaces and may expose it directly if firewalls allow the port.

If direct access is intentional, open the application port in both the VPS provider’s network controls and the host firewall, and restrict the source addresses where possible. For example, a host firewall rule should be added only for the port and clients that actually need it; do not expose an administrative or internal port merely because the process is listening.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

For a public web application, a reverse proxy such as Nginx can accept HTTP or HTTPS, terminate TLS, and forward requests to the JAR on a local port. This keeps the Java listener private and gives you a single place for certificates, host-name routing, and request limits. The proxy and the Java service must agree on the upstream address and port, and the proxy’s health should be tested separately from the application’s local endpoint.

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

Deploy updates without losing the working version

Before replacing a running artifact, record the current JAR name, configuration revision, and service status. Upload the new file, set its owner and mode, then restart:

sudo install -o myapp -g myapp -m 0755 /tmp/app-new.jar /opt/myapp/app.jar
sudo systemctl restart myapp
sudo systemctl status myapp
sudo journalctl -u myapp -n 100 --no-pager

Run the local curl check after each update. If the new release fails, stop the service, restore the known-good JAR, and restart it. Keeping versioned files such as /opt/myapp/releases/app-2026-10-14.jar makes that rollback less error-prone than trying to reconstruct an overwritten artifact.

When a release changes database schema, environment variables, or the required Java version, treat those as deployment changes rather than a simple file copy. Apply them in the order required by the application’s documentation and retain a recovery plan before starting the migration.

How common ways of running a JAR compare

Approach After logout or reboot Restart policy Logs Best use
Direct java -jar in SSH Stops when the shell or connection ends; no boot startup Manual Current terminal First-run smoke test
screen or tmux Survives a disconnected terminal session, but not a normal reboot without additional setup Manual Terminal session Temporary debugging
systemd service Starts at boot when enabled Declarative, such as Restart=on-failure journald Standard single-VPS production deployment
Container or orchestrator Depends on the container runtime and its restart configuration Runtime-specific Runtime-specific Multi-service or repeatable infrastructure

A terminal multiplexer is useful while diagnosing a problem, but it leaves startup, restart, permissions, and logging decisions to an operator. For one Java application on one VPS, systemd supplies those controls without requiring a larger orchestration stack.

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

Framework-specific checks for Spring Boot and Ktor

Spring Boot

Spring Boot commonly reads settings from environment variables, command-line properties, profile-specific configuration, or a configuration file packaged with the application. Confirm the active profile and server port in the startup log. If the service account cannot read an external configuration file or certificate, the application may exit before opening its port.

Ktor

Ktor applications may obtain the port and host from their deployment configuration. Verify that the service’s environment variables match the names used by the application and that the resulting bind address is deliberate. A local curl request should succeed before you troubleshoot provider firewalls or DNS.

Neither framework changes the core deployment model: install the compatible Java runtime, run the JAR manually once, then place the same command under systemd with explicit paths and configuration.

Production checklist

  • Java release verified with java -version and compatible with the JAR.
  • Dedicated service account created; the application does not run as root.
  • JAR, configuration, certificates, and writable data paths have deliberate owners and modes.
  • Manual startup completed successfully and a local endpoint responded.
  • Unit file uses absolute paths, the correct working directory, and the intended environment file.
  • systemctl enable completed, and a controlled restart has been tested.
  • Logs are available through journalctl -u myapp.
  • Application bind address, provider firewall, and host firewall agree with the intended exposure.
  • Public HTTP traffic is routed through a correctly configured reverse proxy when that is the chosen architecture.
  • A previous release and a rollback procedure are available before updates.

Quick command sequence

For a small Ubuntu or Debian deployment, the essential sequence is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install openjdk-17-jre-headless -y
java -version
sudo useradd --system --home /opt/myapp --shell /usr/sbin/nologin myapp
sudo install -d -o myapp -g myapp /opt/myapp
# upload /opt/myapp/app.jar and create /etc/systemd/system/myapp.service
sudo systemctl daemon-reload
sudo systemctl enable myapp
sudo systemctl start myapp
sudo systemctl status myapp
sudo journalctl -u myapp -f

Replace the Java release, account, paths, and service name with the values required by your application. The decisive step is moving from an SSH-owned foreground process to an explicit service definition that systemd can start, monitor, log, and restart.

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.