Skip to content

Java Runtimes

Add minified-java to your build.gradle file:

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.dervarex.minified:minified-java:3.0.0'
}

Launcher.launchMinecraft() already calls JavaManager internally - before starting the game, it reads the required Java feature version from the version JSON and calls JavaManager.ensureJavaVersion(...) for you. If you only care about launching Minecraft, minified-launch pulls this in as a dependency and you don’t need to touch minified-java at all.

Reach for JavaManager directly when you want to resolve or pre-download a runtime before launching - for example, to show a “downloading Java 21…” step in your own UI ahead of time, or to check compatibility without starting the game.


JavaManager keeps its runtime cache under a static, class-wide directory - by default a user-specific application data folder (%APPDATA%\Minified\java on Windows, ~/Library/Application Support/Minified/java on macOS, ~/.local/share/Minified/java on Linux). Call init(...) to override it:

Path javaDirectory = Path.of("<java-directory>");
JavaManager.init(javaDirectory);

Calling init(...) is entirely optional - if you skip it, JavaManager lazily uses its default directory the first time it needs one.


The main entry point is ensureJavaForMinecraftVersion(...). It resolves the Java feature version required by a Minecraft version, compares it against the JVM currently running your launcher, and only downloads a managed runtime if the current one is too old:

JavaInstallation installation = JavaManager.ensureJavaForMinecraftVersion("1.21.11");
Path javaExecutable = installation.executable();
boolean wasDownloaded = installation.managed();

If you already know the required feature version (say, 21), use ensureJavaVersion(int) instead and skip the version-manifest lookup. Both come with a ...Executable(...) shorthand that returns just the Path to the java binary instead of the full JavaInstallation:

Path javaExecutable = JavaManager.ensureJavaExecutable(21);

Managed runtimes are downloaded from Eclipse Temurin and cached under the configured base directory per platform and feature version, so repeated calls for the same version reuse the existing install instead of downloading it again. Concurrent calls for the same runtime are serialized internally, so it’s safe to call ensureJavaVersion(...) from multiple threads without downloading the same archive twice.

JavaInstallation Fields5 available fields
majorVersion

The Java feature version, such as 17, 21, or 25.

Type: int
home

The runtime’s home directory.

Type: Path
executable

The Java executable that should be launched.

Type: Path
managed

Whether this runtime was downloaded and is managed by JavaManager, as opposed to being the JVM already running your launcher.

Type: boolean
releaseName

The vendor release name for managed runtimes, or null for the current JVM.

Type: String

If you just need the required Java feature version without downloading anything, getRequiredJavaVersion(...) is overloaded for every stage a version JSON might be in - a Minecraft version id (fetches and caches the manifest itself), an already-loaded JsonFile/JsonValue, or a cached version JSON on disk:

int required = JavaManager.getRequiredJavaVersion("1.21.11");
if (required > JavaPlatform.majorVersion()) {
System.out.println("Current JVM is too old, Minified will download Java " + required);
}

All overloads return -1 if the required version couldn’t be determined, rather than throwing.


currentRuntime() resolves the JVM your launcher is already running on as a JavaInstallation (with managed set to false), and JavaPlatform offers quick feature-version checks without going through JavaManager at all:

JavaInstallation current = JavaManager.currentRuntime();
boolean atLeast17 = JavaPlatform.isAtLeast(17);

While a managed runtime is being resolved, JavaManager posts progress events to the EventBus it was configured with - EnsureJavaVersionEvent when a download starts, JavaArchiveDownloadEvent while the archive is downloading, and ExtractArchiveEvent while it’s being unpacked. See the Java events section for the full details on each one, including the same shared-EventBus caveat mentioned above.