{"record":{"id":"52f90efab18108df","repo":"oraios/serena","slug":"failed-to-run-java-exe-xshowsettings-propertie","errorCode":null,"errorMessage":"Failed to run '{java_exe} -XshowSettings:properties -version': {exc}","messagePattern":"Failed to run '(.+?) -XshowSettings:properties -version': (.+?)","errorType":"exception","errorClass":"SolidLSPException","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/eclipse_jdtls.py","lineNumber":653,"sourceCode":"        def _inspect_java(java_exe: str) -> tuple[str, int]:\n            \"\"\"\n            Runs ``java -XshowSettings:properties -version`` and parses ``java.home`` and the\n            major version from the output. This is the most reliable cross-platform way to\n            discover the JDK home (works around macOS ``/usr/bin/java`` stub issue).\n\n            :return: (java_home_directory_reported_by_jvm, major_version)\n            \"\"\"\n            try:\n                # both -XshowSettings:properties and -version write to stderr by convention\n                result = subprocess_run(\n                    [java_exe, \"-XshowSettings:properties\", \"-version\"],\n                    capture_output=True,\n                    text=True,\n                    timeout=15,\n                    check=False,\n                )\n            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. \"","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/eclipse_jdtls.py#L635-L671","documentation":"SolidLSPException (wrapping the original exception) thrown by _inspect_java when the probe command '<java> -XshowSettings:properties -version' cannot be executed at all - an OSError (binary missing/not executable) or a subprocess.TimeoutExpired (15s timeout). _inspect_java is the single source of truth for the JDK's real home and version.","triggerScenarios":"_resolve_system_jdk or _resolve_java calls _inspect_java(java_exe) and subprocess.run raises OSError or TimeoutExpired; the underlying OS error is embedded in the message.","commonSituations":"java binary exists on PATH but is not executable; broken symlink; a 'java' shim script that hangs waiting for input; security software blocking process spawn; very slow network filesystem causing the 15s timeout.","solutions":["Verify the java executable runs directly: <java_exe> -XshowSettings:properties -version","Fix permissions: chmod +x <java_home>/bin/java, or fix a broken symlink","Point ls_specific_settings.java.java_home at a healthy JDK instead of the failing one","Investigate what the 'java' shim/hang is doing if a timeout was reported"],"exampleFix":"// before\n$ ls -l $(which java)\nlrwxrwxrwx java -> /opt/jdk11/bin/java  # target deleted\n// after\n$ sudo ln -sf /usr/lib/jvm/java-21/bin/java /usr/local/bin/java","handlingStrategy":"try-catch","validationCode":"import subprocess\ndef java_probe_ok(java_exe: str) -> bool:\n    try:\n        r = subprocess.run([java_exe, \"-XshowSettings:properties\", \"-version\"],\n                           capture_output=True, text=True, timeout=15)\n        return r.returncode == 0 and \"java.home\" in (r.stderr + r.stdout)\n    except (OSError, subprocess.TimeoutExpired):\n        return False","typeGuard":"def is_runnable_java(p: str) -> bool:\n    return os.path.isfile(p) and os.access(p, os.X_OK)","tryCatchPattern":"try:\n    ls = start_jdtls()\nexcept SolidLSPException as e:\n    if \"Failed to run\" in str(e) and \"-XshowSettings\" in str(e):\n        fix_java_binary_permissions_or_path()\n        ls = start_jdtls()\n    else:\n        raise","preventionTips":["Ensure the java binary is executable and not a dangling symlink","Test the exact probe command manually when setting up new machines","Watch for hangs from wrapper/shim scripts on PATH","Keep JDKs on local disks, not slow network mounts, to avoid timeouts"],"tags":["java","subprocess","jvm-probe","process-spawn"],"backgroundTag":"process-spawn-failed","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}