{"record":{"id":"e736e08ace6ed58a","repo":"oraios/serena","slug":"could-not-parse-java-version-from-java-exe-out","errorCode":null,"errorMessage":"Could not parse Java version from '{java_exe}' output. Required: JDK {JDTLS_MIN_JDK_VERSION}+. First lines of output: {output.strip().splitlines()[:5]}","messagePattern":"Could not parse Java version from '(.+?)' output\\. Required: JDK (.+?)\\+\\. First lines of output: (.+?)","errorType":"exception","errorClass":"SolidLSPException","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/eclipse_jdtls.py","lineNumber":670,"sourceCode":"            except (OSError, subprocess.TimeoutExpired) as exc:\n                raise SolidLSPException(f\"Failed to run '{java_exe} -XshowSettings:properties -version': {exc}\") from exc\n\n            output = (result.stderr or \"\") + \"\\n\" + (result.stdout or \"\")\n\n            # parse java.home from \"    java.home = /path/to/jdk\"\n            home_match = re.search(r\"java\\.home\\s*=\\s*(.+)\", output)\n            if not home_match:\n                raise SolidLSPException(\n                    f\"Could not parse java.home from '{java_exe}' output. \"\n                    f\"This usually means '{java_exe}' is not a valid JDK installation. \"\n                    f\"First lines of output: {output.strip().splitlines()[:5]}\"\n                )\n            real_home = home_match.group(1).strip()\n\n            # parse major version from version line: 'openjdk version \"21.0.2\"' or 'java version \"21.0.2\"'\n            version_match = re.search(r'version \"(\\d+)(?:\\.\\d+)*\"', output)\n            if not version_match:\n                raise SolidLSPException(\n                    f\"Could not parse Java version from '{java_exe}' output. \"\n                    f\"Required: JDK {JDTLS_MIN_JDK_VERSION}+. \"\n                    f\"First lines of output: {output.strip().splitlines()[:5]}\"\n                )\n            major = int(version_match.group(1))\n            return real_home, major\n\n        @classmethod\n        def _compute_workspace_hash(\n            cls,\n            repository_root_path: str,\n            jdtls_launcher_jar_path: str,\n            custom_settings: SolidLSPSettings.CustomLSSettings,\n        ) -> str:\n            \"\"\"\n            Compute the JDTLS workspace directory name.\n\n            The launcher jar path is mixed in so that switching JDTLS versions (default","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/eclipse_jdtls.py#L652-L688","documentation":"SolidLSPException thrown by _inspect_java when a java.home was found but no 'version \"<n>...\"' line exists in the probe output, so the major version cannot be determined. JDTLS requires validating JDK 17+, and without a parseable version string the library cannot confirm compatibility.","triggerScenarios":"_resolve_system_jdk/_resolve_java -> _inspect_java where the regex 'version \"(\\d+)(?:\\.\\d+)*\"' matches nothing in stderr+stdout, despite java.home parsing successfully.","commonSituations":"Custom JVM builds with altered -version output; output truncated by a pipe/buffer; tooling that filters or rewrites stderr; extremely exotic runtimes missing the standard version line.","solutions":["Run '<java_exe> -XshowSettings:properties -version' and check whether a standard 'openjdk version \"...\"' line appears","Switch to a standard OpenJDK/Temurin distribution","Reinstall the JDK if the version banner is missing","Point java_home at a different, known-good JDK 17+ installation"],"exampleFix":"// before\n$ java -version\ncustom-jvm: runtime ready  # no version line\n// after\n$ java -version\nopenjdk version \"21.0.2\" 2024-01-16","handlingStrategy":"validation","validationCode":"import subprocess, re\ndef java_version_parseable(java_exe: str) -> bool:\n    r = subprocess.run([java_exe, \"-version\"], capture_output=True, text=True, timeout=15)\n    return bool(re.search(r'version \"(\\d+)(?:\\.\\d+)*\"', (r.stderr or \"\") + (r.stdout or \"\")))","typeGuard":"def has_standard_version_banner(java_exe: str) -> bool:\n    out = probe(java_exe)\n    return re.search(r'(?:openjdk|java) version \"\\d+', out) is not None","tryCatchPattern":"try:\n    ls = start_jdtls()\nexcept SolidLSPException as e:\n    if \"Could not parse Java version\" in str(e):\n        switch_to_standard_openjdk()\n        ls = start_jdtls()\n    else:\n        raise","preventionTips":["Use mainstream OpenJDK builds (Temurin, Corretto, Zulu, distro OpenJDK) whose -version output is standard","Test 'java -version' output when adopting custom or vendor JVMs","Avoid tools that rewrite or filter java's stderr","Reinstall the JVM if the version banner is missing or garbled"],"tags":["java","jvm-probe","version-parsing","output-parsing"],"backgroundTag":"jvm-version-parse-failed","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}