Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk9 min

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

A practical Ubuntu guide to selecting the right Java major, installing it with APT, verifying JRE or JDK, preparing a dedicated server account and opening the game port safely.
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 project, then verify it before you copy in server files. If the project does not specify a version, Ubuntu’s default-jdk is the safest starting point: run sudo apt update followed by sudo apt install default-jdk. Use default-jre only when the server needs a runtime and no Java-based build, plugin or diagnostic tools. Finally, permit only the documented game port in Ubuntu’s firewall and in any cloud-provider firewall.

1. Check the server’s Java requirement first

Java compatibility is determined by the server software, not by Ubuntu alone. Read the project’s installation page, release notes or compatibility matrix and identify the required major version, such as 17 or 21. A server compiled for one major release can refuse to start on another, producing an “unsupported class version” or similar error.

As an Amazon Associate I earn from qualifying purchases.

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.

If the project explicitly requires a major version, install that versioned OpenJDK package. For example:

sudo apt update
sudo apt install openjdk-21-jdk

The package name must match the Java release available for your Ubuntu version. Do not copy an old tutorial that installs Java 8 or Java 11 unless the server documentation specifically requires it. Canonical states that OpenJDK 17 and OpenJDK 21 are TCK-certified on Ubuntu 24.04 LTS; another Ubuntu release can have a different default Java major.

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

When no major version is pinned, install Ubuntu’s moving default:

sudo apt update
sudo apt install default-jdk

default-jdk follows the Java version selected as the default for that Ubuntu release. That makes it convenient for a new installation, but it also means a later Ubuntu package update can move the default to a newer major. A server with a strict compatibility range should use a versioned package instead.

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

2. JRE or JDK: which package belongs on a game server?

A Java Runtime Environment (JRE) supplies what is needed to run Java applications. Ubuntu’s maintained runtime package is default-jre:

sudo apt update
sudo apt install default-jre

A Java Development Kit (JDK) contains the runtime plus development tools, including the javac compiler. Most dedicated game servers can run with a JRE, but a JDK is often the more practical administration choice when you install plugins, compile extensions, run build scripts or need Java diagnostic tools.

Choice Install command Use it when
Ubuntu default JRE sudo apt install default-jre The server is runtime-only and does not require Java tooling.
Ubuntu default JDK sudo apt install default-jdk The server needs a runtime and you may need compilers or administration tools; no fixed major is required.
Versioned JDK sudo apt install openjdk-21-jdk (example) The server documentation pins a Java major and that package is available for your Ubuntu release.

The JRE-versus-JDK choice does not override the required major version. If a project requires Java 17, install the Java 17 runtime or JDK rather than whichever major happens to be Ubuntu’s current default.

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.

3. Prepare Ubuntu and install Java with APT

Update package metadata

Refresh APT’s package index before every installation attempt:

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

This downloads the current package lists from the repositories configured for your Ubuntu release. It does not upgrade the operating system or restart the game server.

Install the selected package

Choose exactly one package path based on the compatibility decision above. APT will show the packages and disk space it plans to use; confirm only after checking that the package name and release are correct.

Confirm the installed Java

Run:

java -version

Read the major version in the output and compare it with the server project’s requirement. The exact wording and patch number are release-dependent, so use the major version for compatibility decisions. If you installed a JDK or your tooling needs a compiler, also run:

javac -version

javac should report the compiler supplied by the installed JDK. A successful java -version check proves that Java is available to your shell; it does not prove that a particular server build, mod set or plugin is compatible.

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

4. When the default package is not the right package

Use a versioned package for a pinned server

If the project’s documentation names Java 21, install openjdk-21-jdk (or the corresponding runtime package when the project explicitly supports runtime-only deployment). Replace 21 with the required major and use the package naming available in your Ubuntu archive.

Understand default-package upgrades

default-jdk and default-jre are metapackages that track Ubuntu’s chosen default. They are useful when the project follows the Ubuntu-supported default, but they are not a promise that every Ubuntu release uses the same Java major. Record the major shown by java -version after installation and after planned operating-system upgrades.

Resolve an unexpected major version

If java -version reports a different major than the server requires, inspect the installed alternatives and packages before launching the server. Install the required versioned package, then select the intended Java executable through Ubuntu’s alternatives mechanism if more than one version is installed. Re-run both version commands and test the server against its documented compatibility matrix.

5. Create a safer account and directory for the server

Do not run a network-facing game process as root. Use a dedicated, unprivileged account and keep the server files in a directory owned by that account. This limits the damage if the server, a plugin or an uploaded world file is compromised.

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

The exact account and directory commands depend on how you manage users and storage, so apply your organization’s standard Linux procedure. The operational arrangement should have these properties:

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.
  • The game process has no administrative privileges.
  • Its worlds, configuration, logs and downloaded components are outside unrelated users’ home directories.
  • Backups and updates can be performed without changing ownership to root.
  • Only the files and directories required by the server are writable by its service account.

After Java is verified, follow the game project’s own instructions to upload or download its server files, accept its EULA where applicable, configure the world and launch it. Because no particular game is named here, there is no universal JAR filename, launch command or Java flag that can be stated safely.

6. Size Ubuntu for the workload, not just the installation

Ubuntu Server documentation lists 64-bit amd64, arm64, ppc64el and s390x architectures. It recommends at least 2 GB of RAM and 5 GB of disk for the Ubuntu Server installation itself. Those figures are operating-system installation minimums, not performance targets for a game world.

A game server’s actual needs vary with concurrent players, world or map size, mods, plugins, simulation distance and view distance. Leave room for the operating system, Java process, world files, logs, backups and temporary update files. Monitor memory and disk usage under a realistic player load before deciding that the machine is adequately sized.

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

Ubuntu Server is intended as a platform for server applications, and Ubuntu’s documentation targets the latest LTS. Keep the operating system and Java packages updated, but schedule restarts around the game server. Test a Java or Ubuntu upgrade against the server build before applying it during a live event.

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

7. Open only the game port

Find the port and protocol in the server documentation

There is no universal game-server port. Use the port and protocol documented by your specific project and the value configured in its server settings. If the server uses a non-default port, the firewall rule must use that exact number. Permit TCP, UDP or both only when the server documentation requires them.

Allow the port with UFW

Ubuntu identifies ufw as its default firewall configuration tool. After confirming the port, allow it with:

sudo ufw allow <port>

Replace <port> with the documented numeric port. Do not open a broad range “just in case.” If you need a protocol-specific rule, use the UFW syntax documented for your Ubuntu release and server protocol.

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

Check the active rules

sudo ufw status

Confirm that the intended rule appears and that unrelated management services remain restricted. Keep your remote administration method available before enabling or tightening firewall rules, or you can lock yourself out.

Check upstream firewalls too

A local UFW rule is only one layer. A VPS or hosted instance may also have a cloud security group, provider firewall or network access-control list. Permit the same documented port and protocol there, and remove temporary broad rules after testing. If the machine is behind a home router, configure port forwarding to the server’s internal address and consider whether exposing the service to the public internet is appropriate.

8. Test the complete path before inviting players

  1. Start the server using the vendor’s documented command under the dedicated account.
  2. Read the startup log for a successful bind and for Java compatibility errors.
  3. On the Ubuntu host, verify that the process is listening on the configured address and port using your normal Linux socket-inspection tool.
  4. From the same host, test a local client connection if the game supports one.
  5. From a separate network, test the public address and documented port. This distinguishes a working process from a blocked provider firewall, router or NAT rule.
  6. Stop the server cleanly and confirm that the world or map saves before making configuration changes.

Keep the listening address deliberate. Binding only to a private interface can be correct for a local network; binding to all interfaces may be required for public access but increases exposure. Use the setting recommended by the game project and your network design.

9. Troubleshoot the failures that occur most often

APT cannot find the package

  • Check the Ubuntu release and architecture.
  • Confirm that the package name is spelled correctly and is available in repositories enabled for that release.
  • Run sudo apt update again and read any repository errors instead of ignoring them.
  • Use the versioned package only when that major is published for your Ubuntu release; otherwise choose a supported package documented by the project.

The Java major is wrong

Inspect installed Java alternatives and package versions. A default package can map to a different major on another Ubuntu release. Install the required versioned OpenJDK package, select the intended executable when multiple versions coexist, and verify with java -version and, for a JDK, javac -version.

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

The server reports an unsupported class-file version

This error indicates a mismatch between the server build and the installed Java major. Do not fix it by randomly trying older Java packages. Consult the server project’s compatibility matrix, install the stated major, select it as the active executable and repeat the startup test.

The server starts locally but nobody can connect

  • Confirm that the server is listening on the expected address and port.
  • Check the UFW rule with sudo ufw status.
  • Verify the cloud provider’s security group or external firewall.
  • For a home connection, verify router port forwarding and the server’s internal address.
  • Confirm that players are using the same address, port and protocol configured by the server.

Java works in your shell but not for the service

A service can run with a different environment or executable path than an interactive shell. Check the service definition or launch script used by the game project, make its Java path explicit when supported, and test again as the dedicated account. Avoid granting the service administrator privileges merely to make an environment problem disappear.

10. A repeatable installation checklist

  • Read the game server’s required Java major and supported operating systems.
  • Choose default-jdk when no major is pinned and development tools are useful.
  • Choose default-jre for a runtime-only installation with no tooling requirement.
  • Choose a versioned openjdk-XX-jdk when the project pins major XX.
  • Run sudo apt update before installation.
  • Verify with java -version; run javac -version when a compiler is needed.
  • Run the server as a dedicated unprivileged account in its own directory.
  • Accept the EULA and use the project’s documented launch procedure where applicable.
  • Size RAM and storage for players, worlds, mods, logs and backups rather than Ubuntu’s 2 GB RAM and 5 GB disk installation minimums.
  • Allow only the documented listening port and protocol in UFW and any upstream firewall.
  • Test locally and from an external network before sharing the address.
  • Schedule Ubuntu and Java updates around the server, then retest compatibility after upgrades.

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 *

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.

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver 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.