Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Install Java with APT on Ubuntu for a Game Server

Install the Java version your game server requires, verify it with APT and Java commands, run the process under a dedicated account, and configure only the required firewall port.
Length11 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.

Install the Java major version required by your game-server software, not an arbitrary version. On Ubuntu, update APT and install either the release-selected default-jdk or the exact versioned package (for example, openjdk-21-jdk). Use default-jre only when the server needs a runtime and no Java-based build or plugin tools. Verify the result with java -version, run the server as an unprivileged account, and allow only its documented listening port through Ubuntu’s firewall and any upstream cloud firewall.

Decide which Java major version the server requires

Java packages are not interchangeable across all server builds. A server compiled for one Java major can refuse to start on an older runtime, while a newer runtime can expose compatibility problems in older libraries or plugins. Begin with the game-server project’s installation or compatibility page and identify the required Java major version (such as 17 or 21). That requirement takes precedence over Ubuntu’s package default.

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.

If the project does not specify a major version, start with Ubuntu’s archive default. The default-jdk package is a moving metapackage: its underlying OpenJDK major can change when you move to a different Ubuntu release. Consequently, record the Ubuntu release and the Java version you actually installed rather than assuming that “default” always means the same number.

Ubuntu 24.04 LTS provides TCK-certified OpenJDK 17 and 21 packages. Certification does not make either version universally correct for every game server; use the version listed by the server vendor or project.

#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.

Default package versus a versioned package

Choice Install command Compatibility behavior Upgrade behavior
Ubuntu default JDK sudo apt install default-jdk Follows the Java major selected for that Ubuntu release. Useful when the server has no pinned requirement. Can move to a newer Java major when Ubuntu changes the metapackage or when you upgrade the operating system; test the server after such changes.
Versioned OpenJDK sudo apt install openjdk-21-jdk (replace 21 with the required major) Pins the package family to the major your server documents. Receives updates within that major while avoiding an automatic switch to a different major; you choose when to migrate.

Package availability depends on the Ubuntu release and enabled repositories. If APT cannot find the exact version, confirm that the release is supported, the required repository components are enabled, and your package lists are current before changing installation sources.

JRE or JDK: what a game server actually needs

A Java Runtime Environment (JRE) contains the components needed to run Java programs. Ubuntu’s maintained runtime metapackage is default-jre. A Java Development Kit (JDK) includes that runtime plus development tools, including the Java compiler and diagnostic utilities.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Need Recommended package Why
Run a prebuilt server only default-jre or the matching versioned JRE package Smaller installation when no compiler or build tooling is required.
Compile plugins, mods or helper code; use build tooling; diagnose with JDK tools default-jdk or the matching versioned JDK package Provides the runtime and javac plus the additional development tools.
Documentation says “Java X” but does not distinguish JRE and JDK Matching JDK It is the safer operational choice because it can run the server and supports tooling if a plugin or update process later needs it.

Do not install an old Java 8 or 11 package merely because a tutorial is old. Install those majors only when the selected server explicitly requires them and the package is available for your Ubuntu release.

Check the Ubuntu host before installing

Use a supported 64-bit Ubuntu Server installation. Ubuntu documents amd64, arm64, ppc64el and s390x as supported Server architectures. The operating-system installation guidance lists at least 2 GB of RAM and 5 GB of disk space; those figures are installation minimums, not adequate targets for a populated game world.

Confirm the host architecture and release so that package and server binaries match:

uname -m
. /etc/os-release
printf '%s %sn' "$NAME" "$VERSION_ID"

Before installing, have the server’s Java major, world directory, documented launch procedure, listening port and protocol available. A port number cannot be chosen safely from Java alone; it belongs to the particular game-server software.

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

Install Java with APT

Option A: install Ubuntu’s default JDK

  1. Refresh package metadata:
    sudo apt update
  2. Install the JDK metapackage:
    sudo apt install default-jdk
  3. When APT shows the package list and disk usage, review it and confirm with Y.

This route is appropriate when the server documentation accepts Ubuntu’s release default or does not pin a Java major.

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

Option B: install a specific OpenJDK major

  1. Refresh package metadata:
    sudo apt update
  2. Substitute the documented major in the package name. For a server requiring Java 21, for example:
    sudo apt install openjdk-21-jdk
  3. Confirm the package transaction and wait for APT to finish.

Use the same pattern for another major only after checking that the package exists in your Ubuntu release. Installing a versioned JDK does not by itself guarantee that an already installed Java command will select it; verify the active alternative in the next section.

Runtime-only installation

For a prebuilt server that explicitly needs no compiler or JDK tooling, Ubuntu documents:

sudo apt update
sudo apt install default-jre

If the project requires a pinned major, select its matching versioned runtime package instead of the default metapackage. A JRE is sufficient only when every server, plugin and maintenance task you will run is compatible with a runtime-only installation.

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.

Verify the active Java installation

Run the executable that the server will use:

java -version

The output format and patch number vary by Ubuntu release and package updates. Check the major number in the output against the server’s requirement; do not rely on the package name alone. If you installed a JDK and need build or plugin tooling, also run:

javac -version

javac should report the expected major. If it is missing after a JDK installation, inspect the package transaction and your command path rather than replacing files manually.

When more than one Java major is installed

Multiple JDKs can coexist. Ubuntu uses alternatives to select the command reached through the normal path. Inspect and, if necessary, select the required executable:

update-alternatives --list java
sudo update-alternatives --config java

Choose the path whose major matches the server. Repeat the check with update-alternatives --config javac when compilation tools must use the same major. Run java -version again after changing the selection. A service started by a supervisor can have a different environment from your interactive shell, so test the command in the service’s actual launch context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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)

Create a safer account and directory for the server

Do not run a network-facing game process as root. Create a dedicated unprivileged account and keep the server files separate from system directories and from unrelated applications:

sudo adduser --system --home /srv/game-server --group game-server
sudo install -d -o game-server -g game-server /srv/game-server

The account name and path are examples; use a name that fits your host. Copy or download the server files according to that project’s documentation, then assign ownership only to the dedicated account. Avoid granting it sudo access. Keep backups, world data and logs in known locations, and ensure the account can write the directories the server needs without making the whole filesystem writable.

Accept a server EULA only when that project requires it and only after reading its terms. The EULA file name, acceptance setting and launch command differ by game, so follow the selected project’s instructions rather than copying a command from another server.

Start the game server with the project’s documented command

Change to the server directory and run the exact command supplied by the server project. Since no particular game is specified here, there is no universal filename, memory flag or startup command to substitute:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo -u game-server -H sh -c 'cd /srv/game-server && <documented-server-command>'

Replace the text in angle brackets with the project’s real command; do not type the brackets. If the documentation specifies JVM options, place them exactly where it requires. Memory settings, garbage-collection options, mod loaders and Java module flags are server-specific and should not be invented from a generic tutorial.

For an unattended host, run the process under a service manager or a terminal multiplexer as documented for your server. Whichever method you choose, configure log retention, restart behavior and a clean shutdown so that world data is not damaged during maintenance.

Open only the required network port

A server that works locally but cannot be reached remotely usually has a binding or firewall problem, not a Java installation problem. First identify the port and protocol in the game-server documentation and confirm that the process is listening on the intended address.

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 ss -ltnup

Look for the server’s process and documented port. Binding to a loopback address such as 127.0.0.1 makes it reachable only from the host; a remote-access server generally needs to bind to the host’s appropriate interface, as the game documentation explains.

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

Configure Ubuntu’s UFW firewall

Ubuntu identifies ufw as its default firewall configuration tool. Allow only the documented port and protocol, then inspect the active rules:

sudo ufw allow <port>/tcp
sudo ufw status

Use /udp instead when the server documentation specifies UDP, or create separate rules when it genuinely uses both protocols. Replace <port> with the real number; never open a broad range “just in case.” If UFW is inactive, enable it only after allowing your administration method (for example, SSH) so you do not lock yourself out:

sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status verbose

The SSH profile name can vary if you use a nonstandard configuration. Verify your existing remote-access rule before enabling the firewall.

Check the provider or upstream firewall

Cloud VPS and hosted-network platforms often place a security group, network ACL or external firewall in front of the Ubuntu host. The port must be allowed there as well as in UFW, with the correct protocol and source range. For a private server behind a home router, configure port forwarding to the host’s private address and account for the ISP’s inbound restrictions. Limit source addresses when the game supports a private player group; otherwise the port is exposed to the public internet and should be protected with the game’s own authentication and update practices.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Size the machine for the world, not the operating-system minimum

The documented Ubuntu minimum of 2 GB RAM and 5 GB disk describes installing Ubuntu Server. A game world can need considerably more, depending on concurrent players, world size, mods, simulation distance, logging and backups. Treat those variables as capacity inputs rather than promising a universal Java heap size.

  • RAM: leave room for Ubuntu, the Java process, native memory, file cache and monitoring. Increase allocation when player count or mod complexity grows, while avoiding a heap so large that the host swaps.
  • Storage: budget for the world, generated chunks, logs, downloads, snapshots and at least one off-host backup. Monitor free space because a full filesystem can stop both the server and its logs.
  • CPU: check the server’s tick or simulation guidance. Some workloads depend more on single-thread performance than on total core count; mods and plugins can change that balance.
  • Architecture: use a server build and native dependencies that support the host architecture. amd64 is common, while arm64, ppc64el and s390x are also listed for Ubuntu Server; compatibility still belongs to the game project.

Measure during realistic play sessions. Record memory pressure, CPU saturation, tick-time warnings and disk growth before changing Java flags or moving to a larger host.

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.

Self-hosting or a VPS: operational trade-offs

Factor Self-hosted Ubuntu machine VPS
Administration You maintain hardware, power, operating-system updates and local networking. The provider supplies the virtual hardware; you still maintain Ubuntu, Java, the game server and backups.
Resources Capacity depends on the machine and what else runs on it; noisy neighboring applications are under your control. Plan size gives more predictable allocated resources, subject to the provider’s performance policy.
Connectivity You may need router forwarding, a stable address and ISP support for inbound traffic. Usually includes a public network interface and provider-level security groups, but those rules must be configured.
Recovery Hardware failure can require local replacement unless you maintain off-site backups. Snapshots and replacement instances may simplify recovery, but they are not a substitute for tested game-world backups.

Both choices use the same APT installation and Java verification process. Select based on the player community, uptime expectations, network control and your willingness to operate hardware.

Keep Java and Ubuntu maintained without surprising the server

APT security updates are important, but a Java major change can affect an older server or plugin set. Apply routine package updates during a maintenance window:

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

Before upgrading Ubuntu or intentionally changing Java majors, make a restorable backup of the world and configuration, record the current java -version, and test the server build and plugins on a staging copy. Schedule a controlled restart rather than terminating a live process. Keep the server’s compatibility matrix with your maintenance notes so you can roll back to the previously supported major if testing fails.

Troubleshooting APT, Java and connections

APT says it cannot locate the package

  • Check the spelling and package name for your Ubuntu release.
  • Run sudo apt update and look for repository or signature errors.
  • Confirm that the release is supported and the required archive components are enabled.
  • Use apt policy default-jdk or apt policy openjdk-21-jdk to see whether APT has a candidate version.

Do not download an unrelated binary installer simply to bypass an APT error; resolve the release or repository issue first, or choose a package supported by that release.

java -version reports an unexpected major

Another JDK may already be installed, or the alternatives selection may still point to it. Inspect update-alternatives --list java, select the required path with sudo update-alternatives --config java, and verify again. If a service manager launches a different Java binary, inspect its environment and use an explicit path when the server documentation permits it.

The server reports an unsupported class-file version

This error means the server or one of its components was compiled for a Java major that does not match the active runtime. Read the server project’s compatibility matrix, install or select the required major, and repeat java -version. Do not “fix” the message by randomly trying newer versions; the project may require an older supported runtime.

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

The process runs locally but players cannot connect

  1. Confirm that the process is running and listening with sudo ss -ltnup.
  2. Check the configured bind address and documented port and protocol.
  3. Confirm the matching UFW rule with sudo ufw status verbose.
  4. Check the cloud security group, provider firewall or router forwarding rule.
  5. Test from a network outside the server’s LAN; a local test can succeed even when inbound traffic is blocked upstream.

Change one layer at a time and record the result. Opening every port or disabling the firewall hides the fault and creates unnecessary exposure.

Installation checklist

  • Identify the server’s documented Java major; if none is specified, use Ubuntu’s default-jdk.
  • Install with sudo apt update followed by the appropriate JDK, versioned JDK, or runtime package.
  • Verify both java -version and, when tooling is needed, javac -version.
  • Run the process as a dedicated unprivileged account in its own directory.
  • Follow the selected server’s EULA and launch instructions instead of using a generic command.
  • Match UFW and upstream firewall rules to the documented port and protocol only.
  • Provide resources based on players, world data and mods; Ubuntu’s 2 GB RAM and 5 GB disk figures are not game-performance targets.
  • Back up the world, test Java or Ubuntu upgrades, and schedule controlled restarts.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.