JetBrains/intellij-community · error · IllegalStateException
\nThe version of the executed Ant is not compatible with the
Error message
\nThe version of the executed Ant is not compatible with the JRE version {jreVersion}. \nTo use Ant with this Java version, download an older version of Ant, unpack it and specify the path to it on the 'Execution' tab in the 'Build File Properties' dialog (accessible via the 'Ant Build' tool window -> Properties button). What it means
AntMain2 is the IDE-injected entry point for running Ant builds inside IntelliJ. It first tries to launch Ant via its launcher class; if the JVM throws UnsupportedClassVersionError (Ant bytecode newer than the JRE, or an old Ant build with a new JRE combination), it wraps it in a stackless IllegalStateException explaining that the executed Ant version is incompatible with the JRE and how to point IDEA at an older Ant.
Source
Thrown at java/java-runtime/src/com/intellij/rt/ant/execution/AntMain2.java:50
return;
}
catch (ClassNotFoundException e) {
// ignore
}
// fallback: try the newer approach, launcher
// This approach is less preferred in our case, but still...
// From the ant documentation: "You should start the launcher with the most minimal classpath possible, generally just the ant-launcher.jar."
final Class<?> antLauncher = Class.forName("org.apache.tools.ant.launch.Launcher");
antLauncher.getMethod("main", new Class[]{args.getClass()}).invoke(null, new Object[]{args});
}
catch (UnsupportedClassVersionError ucv) {
String jreVersion = System.getProperty("java.version");
String message = "\nThe version of the executed Ant is not compatible with the JRE version " + jreVersion + ". " +
"\nTo use Ant with this Java version, download an older version of Ant, " +
"unpack it and specify the path to it on the 'Execution' tab in the 'Build File Properties' dialog " +
"(accessible via the 'Ant Build' tool window -> Properties button).";
throw new IllegalStateException(message) {
@Override
public synchronized Throwable fillInStackTrace() {
return this;
}
};
}
}
}
View on GitHub (pinned to be881553f2)
Solutions
- Open Ant Build tool window -> Properties ('Build File Properties') -> 'Execution' tab and set the path to a compatible Ant distribution (download an older/newer Ant matching your JRE and unpack it locally).
- Alternatively change the JRE used for the Ant run configuration to one matching the Ant bytecode version (e.g. Ant 1.10 needs Java 8+).
- Verify with 'java -version' and the Ant release notes for its minimum Java level; align both sides.
Defensive patterns
Strategy: fallback
Prevention
- Align Ant version with JRE class-file support before building.
- Configure a local compatible Ant in Build File Properties -> Execution.
- Check 'java -version' vs Ant minimum Java requirement when builds change environments.
When it happens
Trigger: Running an Ant build in IDEA where the selected Ant distribution's classes were compiled for a different class-file version than the selected JRE — e.g. Ant 1.10.x requiring Java 8+ run on Java 7, or a modern Ant nightly (requires 11+) run on an old JRE. Class.forName("org.apache.tools.ant.launch.Launcher") or the reflective main invocation throws UnsupportedClassVersionError.
Common situations: Upgrading the project JRE while keeping an old bundled Ant; pointing the Ant Build tool window at an incompatible Ant home; CI agents with mismatched JDK/Ant pairs; running legacy Ant-based projects on modern or legacy JVMs.
Related errors
- No target class for the instance method is found: method par
- ''{0}'' does not exist
- Prompt is null
- Selected InputHandler should be used by Intellij IDEA
- No junit.jar
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/7e401e5baa0145c4.
Report an issue: GitHub.