{"record":{"id":"4bbec7165249a3cf","repo":"elastic/elasticsearch","slug":"s-requires-java-s-your-system-s","errorCode":null,"errorMessage":"%s requires Java %s:, your system: %s","messagePattern":"(.+?) requires Java (.+?):, your system: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"libs/core/src/main/java/org/elasticsearch/jdk/JarHell.java","lineNumber":280,"sourceCode":"    }\n\n    /** inspect manifest for sure incompatibilities */\n    private static void checkManifest(Manifest manifest, Path jar) {\n        // give a nice error if jar requires a newer java version\n        String targetVersion = manifest.getMainAttributes().getValue(\"X-Compile-Target-JDK\");\n        if (targetVersion != null) {\n            checkJavaVersion(jar.toString(), targetVersion);\n        }\n    }\n\n    /**\n     * Checks that the java specification version {@code targetVersion}\n     * required by {@code resource} is compatible with the current installation.\n     */\n    public static void checkJavaVersion(String resource, String targetVersion) {\n        Version version = Version.parse(targetVersion);\n        if (Runtime.version().feature() < version.feature()) {\n            throw new IllegalStateException(\n                String.format(Locale.ROOT, \"%s requires Java %s:, your system: %s\", resource, targetVersion, Runtime.version().toString())\n            );\n        }\n    }\n\n    private static void checkClass(Map<String, Path> clazzes, String clazz, Path jarpath) {\n        if (clazz.equals(\"module-info\") || clazz.endsWith(\".module-info\")) {\n            // Ignore jigsaw module descriptions\n            return;\n        }\n        Path previous = clazzes.put(clazz, jarpath);\n        if (previous != null) {\n            if (previous.equals(jarpath)) {\n                // throw a better exception in this ridiculous case.\n                // unfortunately the zip file format allows this buggy possibility\n                // UweSays: It can, but should be considered as bug :-)\n                throw new IllegalStateException(\n                    \"jar hell!\"","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/core/src/main/java/org/elasticsearch/jdk/JarHell.java#L262-L298","documentation":"Thrown by JarHell.checkJavaVersion when a JAR's manifest declares an 'X-Compile-Target-JDK' attribute whose Java feature version is higher than the running JVM's feature version. Elasticsearch scans every JAR on the classpath at startup and refuses to boot if any JAR requires a newer JDK than the one running. The comparison is purely on the feature number (e.g. 21 vs 17), not the full version string.","triggerScenarios":"A JAR on the classpath (class dir, module jar, or plugin jar) has a MANIFEST.MF with 'X-Compile-Target-JDK: <version>' where the numeric feature is greater than Runtime.version().feature(). Triggered during checkManifest() which is called from the jar-hell scan loop iterating over every classpath element.","commonSituations":"Running Elasticsearch built for JDK 21 on a JDK 17 runtime; installing a plugin compiled against a newer JDK onto an older node; CI using JAVA_HOME pointing at an older toolchain than the build expected; downgrading the JVM after building.","solutions":["Upgrade the runtime JDK to a feature version >= the one named in the error message (e.g. install JDK 21 if the JAR requires Java 21).","Verify JAVA_HOME and PATH resolve to the intended JDK: run 'java -version' as the ES user.","Rebuild or reinstall the offending JAR/plugin against the JDK you actually run, so its X-Compile-Target-JDK manifest attribute matches.","If the JAR is third-party, replace it with a build compiled for your target JDK feature level."],"exampleFix":"// before: running on JDK 17 with a JAR requiring 21\n// java -version -> 17.0.x\n\n// after: install and select JDK 21+\nexport JAVA_HOME=/path/to/jdk-21\nbin/elasticsearch","handlingStrategy":"validation","validationCode":"// Before scanning/launching, verify the runtime meets every JAR's requirement\nimport java.lang.Runtime;\nimport java.util.jar.*;\n\nvoid assertJdkCompatible(List<Path> jars) throws IOException {\n  int runtimeFeature = Runtime.version().feature();\n  for (Path jar : jars) {\n    try (var f = new JarFile(jar.toFile())) {\n      var v = f.getManifest().getMainAttributes().getValue(\"X-Compile-Target-JDK\");\n      if (v != null && Runtime.version().parse(v).feature() > runtimeFeature) {\n        throw new IllegalStateException(jar + \" requires Java \" + v);\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin JAVA_HOME to a JDK feature version >= the maximum declared X-Compile-Target-JDK across all classpath jars.","In CI, assert 'java -version' feature >= the project's source/target before launching ES.","Validate plugin jars against the running JDK before installing them into a node."],"tags":["jar-hell","jdk-version","startup","compatibility"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}