{"record":{"id":"7336e6acd988d9a6","repo":"apache/maven","slug":"could-not-parse-current-java-version","errorCode":null,"errorMessage":"Could not parse current Java version","messagePattern":"Could not parse current Java version","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java","lineNumber":65,"sourceCode":"            if (!matchesVersion(requiredJavaVersion, currentJavaVersion)) {\n                throw new IllegalStateException(\"Required Java version \" + requiredJavaVersion\n                        + \" is not met by current version: \" + currentJavaVersion);\n            }\n        }\n    }\n\n    boolean matchesVersion(String requiredVersion, String currentVersion) {\n        VersionConstraint constraint;\n        try {\n            constraint = versionScheme.parseVersionConstraint(requiredVersion);\n        } catch (InvalidVersionSpecificationException e) {\n            throw new IllegalArgumentException(\"Invalid 'requiredJavaVersion' given in plugin descriptor\", e);\n        }\n        Version current;\n        try {\n            current = versionScheme.parseVersion(currentVersion);\n        } catch (InvalidVersionSpecificationException e) {\n            throw new IllegalStateException(\"Could not parse current Java version\", e);\n        }\n        if (constraint.getRange() == null) {\n            return constraint.getVersion().compareTo(current) <= 0;\n        }\n        return constraint.containsVersion(current);\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java#L47-L73","documentation":"MavenPluginJavaPrerequisiteChecker.matchesVersion validates a plugin descriptor's requiredJavaVersion against the running JVM. The required side is parsed as a VersionConstraint; the current side is System.getProperty(\"java.version\") parsed with Resolver's GenericVersionScheme. If that property value is null, blank, or otherwise unparseable, Maven cannot even form the comparison and throws IllegalStateException.","triggerScenarios":"Executing a plugin whose descriptor declares requiredJavaVersion (set via maven-plugin-plugin from the plugin POM) while the JVM's java.version system property has a value the GenericVersionScheme rejects: null, empty, or an exotic nonstandard string. Reached from MavenPluginPrerequisitesChecker.accept during plugin loading/prerequisite checks.","commonSituations":"Launcher scripts or tests that override -Djava.version with a nonstandard value; stripped-down/custom JVM distributions reporting unusual version strings; embedding Maven in a process where system properties were sanitized before the build starts.","solutions":["Print the actual value with `mvn -version` and `java -version`; confirm the JVM reports a standard version string.","Remove any -Djava.version=... override from MAVEN_OPTS, CI environment, or launcher scripts and let the JVM report its own value.","Switch to a mainstream JDK distribution whose java.version follows the standard scheme.","Pin an older version of the offending plugin that does not declare requiredJavaVersion, or rebuild the plugin with a corrected/simplified value."],"exampleFix":"# before: launcher forces a nonstandard value\nmvn -Djava.version=\"17.0.1 custom build\" clean\n\n# after: let the JVM report its own version\nmvn clean","handlingStrategy":"validation","validationCode":"String v = System.getProperty(\"java.version\");\nif (v == null || v.isBlank() || !v.matches(\"[0-9]+(\\\\.[0-9]+){0,3}([-._+].*)?\")) {\n    throw new IllegalStateException(\"java.version is not a parseable version string: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n    pluginManager.checkPrerequisites(descriptor);\n} catch (IllegalStateException e) {\n    if (e.getCause() instanceof org.eclipse.aether.version.InvalidVersionSpecificationException ives) {\n        // environment problem, not a plugin choice problem: fix the JVM/launcher\n    }\n    throw e;\n}","preventionTips":["Never pass -Djava.version on the Maven command line; it shadows the JVM-reported value","Pin the JDK in CI to a standard distribution so java.version is well-formed","In launcher/embedder code, whitelist system properties forwarded to the Maven process"],"tags":["java","version","prerequisites","plugin","system-properties"],"backgroundTag":"unparseable-version-string","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}