elastic/elasticsearch · error · IllegalArgumentException
expected zero arguments but was {}
Error message
expected zero arguments but was {} What it means
JavaVersionChecker.main rejects any command-line arguments: the tool takes none. If args.length != 0 it throws IllegalArgumentException printing the supplied args. The tool exists only to verify java.specification.version >= 21 and exit non-zero otherwise.
Source
Thrown at distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersionChecker.java:25
* License v3.0 only", or the "Server Side Public License, v 1".
*/
package org.elasticsearch.tools.java_version_checker;
import java.util.Arrays;
import java.util.Locale;
/**
* Java 8 compatible main to check the runtime version
*/
final class JavaVersionChecker {
private JavaVersionChecker() {}
public static void main(final String[] args) {
// no leniency!
if (args.length != 0) {
throw new IllegalArgumentException("expected zero arguments but was " + Arrays.toString(args));
}
final int MIN_VERSION = 21;
final int version;
String versionString = System.getProperty("java.specification.version");
if (versionString.equals("1.8")) {
version = 8;
} else {
version = Integer.parseInt(versionString);
}
if (version >= MIN_VERSION) {
return;
}
final String message = String.format(
Locale.ROOT,
"The minimum required Java version is %d; your Java version %d from [%s] does not meet that requirement.",
MIN_VERSION,View on GitHub (pinned to db6a809a66)
Solutions
- Invoke java-version-checker with no arguments: java -jar java-version-checker.jar.
- If your launcher needs flags, pass them to the JVM (-J args) or to the surrounding script, not as program args.
- Confirm the Gradle 'java-version-checker' task is the one launching it (it always passes zero args).
Example fix
// before java -jar java-version-checker.jar --check 21 // after java -jar java-version-checker.jar
Defensive patterns
Strategy: validation
Validate before calling
if (args != null && args.length != 0) throw new IllegalArgumentException("java-version-checker takes no args");
// invoke main with new String[0] Prevention
- Always call the checker with zero program args.
- Pass JVM flags via -J or the launcher, not as program args.
When it happens
Trigger: Invoking the java-version-checker jar/main with any CLI args (flags, --help, a path). The entrypoint is meant to be called by the Gradle/launcher shim with no arguments.
Common situations: Someone ran the checker jar manually with flags; a custom launcher script appended arguments; debugging hook passed extra args.
Related errors
- Task {} is not configured to use any clusters. Be sure to ca
- Can not use {} with {}
- Cannot specify more than one trust method (CA=%s, trustStore
- Task {} can't use test cluster from another project {}
- SSL trust has been configured, but [{}] is not a 'https' URL
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/e4ca66934abd2a88.
Report an issue: GitHub.