Guide
The Minecraft Java Version for Mods
Choosing the Minecraft Java version for mods is usually invisible, because the official launcher bundles the right runtime and switches between them silently. It becomes a problem the moment you use a third-party launcher, run a server, or install Java system-wide for something else.
The mapping is short, the error is unmistakable once you know it, and the fix takes a couple of minutes.
The mapping, which is all most people need
Minecraft requires a specific Java major version depending on which Minecraft version you are running. Mods are compiled against the same target, so a mod for 1.21 will not run on a Java 17 runtime.
Three versions cover essentially everything currently played.
| Minecraft version | Java required | Notes |
|---|---|---|
| 1.20.5 and newer | Java 21 | Current standard |
| 1.18 – 1.20.4 | Java 17 | The long-running middle era |
| 1.17 | Java 16 | Brief transitional version |
| 1.16.5 and older | Java 8 | Classic Forge packs |
What a mismatch looks like
The error is UnsupportedClassVersionError, and it includes a class file version number that tells you exactly what was expected.
Class file version 65.0 means Java 21. 61.0 means Java 17. 60.0 is Java 16, and 52.0 is Java 8. The number is always the Java version plus 44, which is a piece of trivia that saves looking it up.
The message names the class that failed to load, which usually identifies the mod. But the fix is the same regardless of which mod triggered it: change the runtime, not the mod.
Reading the version numbers
java.lang.UnsupportedClassVersionError:
net/example/Mod has been compiled by a more recent
version of the Java Runtime (class file version 65.0),
this version recognizes up to 61.0
# 65.0 = Java 21 needed. 61.0 = Java 17 installed.Checking what you have
Open a terminal and run java -version. It prints the version of whatever Java is first on your system path.
The important caveat: this is not necessarily the Java that Minecraft uses. The official launcher bundles its own runtimes and ignores your system installation entirely, which is why the official launcher rarely has this problem.
To see what the game actually used, look at the crash report's system details section, which records the Java version and the path it came from.
Checking your system Java
java -version
openjdk version "21.0.3" 2024-04-16
-> Java 21 is what your PATH resolves to
# Minecraft may still be using a bundled runtime instead.Why the official launcher usually avoids this
Mojang ships Java runtimes with the launcher and picks the correct one per profile automatically. If you only ever use the official launcher, you may never encounter a Java version problem.
The exception is when a profile has been configured with a custom executable, which some older guides recommend. If the JVM path field in a profile's settings points somewhere specific, that is what will be used, and it may be the wrong version.
Clearing that field returns the profile to the bundled runtime and fixes the problem outright.
Third-party launchers need telling
Prism Launcher, MultiMC and similar tools do not bundle runtimes by default. They use whatever Java you point them at, per instance.
Prism will usually detect installed Java versions and can download one for you if none is suitable. Open the instance settings, find the Java section, and confirm the selected version matches the table above.
The advantage of this arrangement is that each instance can use a different Java version, which is exactly what you want if you play both a 1.12.2 pack and a current one. The disadvantage is that it is one more thing to get wrong.
Installing the right Java
Download from Adoptium, which publishes free, well-maintained OpenJDK builds for every platform. Take the version you need, install it, and point your launcher at it.
You can have several Java versions installed simultaneously. They do not conflict, and instance launchers can select between them per instance. There is no need to uninstall an old one to add a new one.
Avoid the oracle.com consumer Java download unless you specifically want it. It installs a browser-oriented runtime and its licensing has been changed more than once. Adoptium is what the Minecraft community actually uses.
Servers are where this bites hardest
A server has no launcher managing runtimes for it. It uses whatever java command is on the path, which is frequently the wrong one on a machine that has had Java installed for some other purpose.
The fix is to invoke the specific runtime by full path in your start script rather than relying on the path. It is explicit, it survives system updates, and it removes an entire category of confusion.
On a rented server, the host usually offers a Java version selector in the control panel. Set it to match your pack rather than leaving it on the default.
Pin the runtime in your start script
# Instead of relying on PATH:
java -Xmx6G -jar server.jar nogui
# Be explicit:
/usr/lib/jvm/temurin-21/bin/java -Xmx6G -jar server.jar noguiNewer Java is not better here
There is a tempting assumption that installing the newest Java available will satisfy everything. It will not.
Minecraft versions are tested against specific Java versions, and running 1.16.5 on Java 21 fails — often with obscure errors rather than a clean version message, because older Forge builds use internals that newer Java removed.
Match the table. Newer is not compatible with older in this direction, and 'I installed the latest Java' is a common reason an old pack stopped working.
A two-minute diagnosis
If you see UnsupportedClassVersionError, read the class file version number and subtract 44 to get the Java version needed. Compare that with what your launcher is using. Install the correct one from Adoptium if you do not have it, point the instance at it, and relaunch.
If you are on the official launcher, check whether a custom Java path has been set on that profile and clear it. That resolves nearly every case there.
- Read the class file version from the error message.
- Subtract 44 to get the Java version needed.
- Check what your launcher or instance is actually using.
- Install the correct build from Adoptium if missing.
- Point that instance at it explicitly, then relaunch.
Keeping several versions straight
Anyone playing both modern and classic packs will end up with two or three Java installations, and it is worth being deliberate about it.
Install Java 8, 17 and 21 from Adoptium and leave them all in place. Configure each instance to use the correct one explicitly rather than relying on a system default, which can change when something else updates.
Note the choice somewhere. When a pack breaks six months later, knowing which Java it was working under is the fastest route back.
JRE or JDK — does it matter?
Adoptium and similar sites offer both a JRE and a JDK, and the distinction confuses people who only want to play a game.
A JRE is the runtime alone: enough to run Java programs, nothing more. A JDK is the runtime plus development tools — a compiler, a debugger and various utilities.
For playing Minecraft, either works. The JRE is smaller. For running a server, either works too.
Take the JDK if you are unsure, because some launchers and tools expect utilities that ship only with it, and the extra disk space is trivial. The only situation where it genuinely matters is if you intend to write mods yourself, where a JDK is required.
32-bit Java is a trap
Occasionally someone installs a 32-bit Java build, usually by taking the default download on an older page, and then cannot work out why they are unable to allocate more than about 1.5GB of memory.
A 32-bit process cannot address more than roughly 2GB regardless of how much physical memory the machine has. Setting -Xmx4G on a 32-bit runtime either fails to start or silently caps.
Every modern machine should be running a 64-bit build. Check with java -version, which prints '64-Bit Server VM' on a correct installation.
If you find a 32-bit runtime, uninstall it and take the x64 build. This is rare in 2026 but it still catches people using older hardware or following outdated guides.
When the launcher and the mod disagree
A specific and confusing case: the game launches, most mods load, and one fails with a version error while everything else is fine.
This means that single mod was compiled for a newer Java than the rest. It happens when an author updates their build tooling ahead of the ecosystem, and it is a bug on their side rather than a misconfiguration on yours.
Check the mod's page and issue tracker — this kind of thing is usually reported within days and fixed shortly after. In the meantime, an older build of that mod will normally work.
Do not raise your Java version to accommodate one mod if the rest of your pack targets an older one. You will fix one failure and create several.
Questions people actually ask
- What Java version does Minecraft 1.21 need?
- Java 21. Every Minecraft version from 1.20.5 onward requires it, and mods for those versions are compiled against it too.
- What Java version does Minecraft 1.20.1 need?
- Java 17. The 1.18 through 1.20.4 range all use it, which covers a large share of currently popular modpacks.
- What does class file version 65.0 mean?
- It means the code was compiled for Java 21 and your runtime is older. The class file number is always the Java version plus 44, so 61.0 is Java 17 and 52.0 is Java 8.
- Do I need to install Java separately?
- Not for the official launcher, which bundles its own runtimes. Third-party launchers and servers do need Java installed, and Adoptium is the usual source.
- Can I have multiple Java versions installed?
- Yes, and if you play both modern and classic packs you should. They do not conflict, and instance launchers select between them per instance.
- Why does my old modpack fail on new Java?
- Older Minecraft and Forge versions rely on Java internals that newer releases removed. Java 21 genuinely cannot run a 1.12.2 pack — install Java 8 for it.
- Where should I download Java from?
- Adoptium, which publishes free OpenJDK builds for every platform. Avoid the consumer download on oracle.com unless you specifically want it.
- How do I check which Java Minecraft used?
- Look at the system details section at the end of a crash report. It records the runtime version and the path it came from, which is more reliable than checking your system Java.
- My server uses the wrong Java version.
- Invoke the runtime by full path in the start script rather than relying on the system path. On a rented server, set the Java version in the host's control panel.
- Is Java 21 backwards compatible with old mods?
- No, not in the way people hope. Newer Java runs newer code; old Minecraft versions require the old runtimes they were built against.
- Should I install the JRE or the JDK?
- Either runs Minecraft. Take the JDK if unsure — some launchers expect utilities that only ship with it, and the extra size is negligible. A JDK is required only if you intend to write mods.
- Why can I only allocate 2GB of RAM?
- You are almost certainly running a 32-bit Java build, which cannot address more regardless of physical memory. Run java -version and confirm it says 64-Bit Server VM; if not, install the x64 build.
- One mod fails on Java version but the rest work.
- That mod was compiled against a newer Java than the rest of your pack — usually an author-side build mistake. Use an older build of that mod rather than raising your Java version for the whole setup.
Sources & further reading
Read next
- Minecraft Forge: What It Is and Which Loader You Actually Need
Minecraft Forge explained — what it does, when to use it instead of Fabric or NeoForge, how to install it, and why Forge is no longer the default choice.
- Minecraft Exit Code 1: What It Means and How to Fix It
Minecraft exit code 1 is not an error message, it is the absence of one. Here is how to find the real cause in the log and fix each of the five things that produce it.
- How to Read a Minecraft Crash Report
How to read a Minecraft crash report: which four lines matter, how to spot the guilty mod, and why the bottom of the file is almost always a distraction.
- How to Install Fabric for Minecraft
How to install Fabric on Windows, macOS and Linux, plus Fabric API, Mod Menu and the four mods worth adding immediately afterwards.
Back to the full How to Mod Minecraft guide for the whole install walkthrough from the beginning.

Sukie · Editor
Sukie runs How to Mod Minecraft. She writes and edits every guide on the site, works through each install path herself before publishing, and rewrites anything that turns out to be wrong. The focus here is narrow on purpose: getting mods, loaders and modded servers working without wading through forum threads.
About this site · How guides are checked · Last updated September 4, 2026
NOT AN OFFICIAL MINECRAFT PRODUCT. NOT APPROVED BY OR ASSOCIATED WITH MOJANG OR MICROSOFT.