oraios/serena · error · SolidLSPException

Failed to run '{java_exe} -XshowSettings:properties -version

Error message

Failed to run '{java_exe} -XshowSettings:properties -version': {exc}

What it means

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.

Source

Thrown at src/solidlsp/language_servers/eclipse_jdtls.py:653

        def _inspect_java(java_exe: str) -> tuple[str, int]:
            """
            Runs ``java -XshowSettings:properties -version`` and parses ``java.home`` and the
            major version from the output. This is the most reliable cross-platform way to
            discover the JDK home (works around macOS ``/usr/bin/java`` stub issue).

            :return: (java_home_directory_reported_by_jvm, major_version)
            """
            try:
                # both -XshowSettings:properties and -version write to stderr by convention
                result = subprocess_run(
                    [java_exe, "-XshowSettings:properties", "-version"],
                    capture_output=True,
                    text=True,
                    timeout=15,
                    check=False,
                )
            except (OSError, subprocess.TimeoutExpired) as exc:
                raise SolidLSPException(f"Failed to run '{java_exe} -XshowSettings:properties -version': {exc}") from exc

            output = (result.stderr or "") + "\n" + (result.stdout or "")

            # parse java.home from "    java.home = /path/to/jdk"
            home_match = re.search(r"java\.home\s*=\s*(.+)", output)
            if not home_match:
                raise SolidLSPException(
                    f"Could not parse java.home from '{java_exe}' output. "
                    f"This usually means '{java_exe}' is not a valid JDK installation. "
                    f"First lines of output: {output.strip().splitlines()[:5]}"
                )
            real_home = home_match.group(1).strip()

            # parse major version from version line: 'openjdk version "21.0.2"' or 'java version "21.0.2"'
            version_match = re.search(r'version "(\d+)(?:\.\d+)*"', output)
            if not version_match:
                raise SolidLSPException(
                    f"Could not parse Java version from '{java_exe}' output. "

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Verify the java executable runs directly: <java_exe> -XshowSettings:properties -version
  2. Fix permissions: chmod +x <java_home>/bin/java, or fix a broken symlink
  3. Point ls_specific_settings.java.java_home at a healthy JDK instead of the failing one
  4. Investigate what the 'java' shim/hang is doing if a timeout was reported

Example fix

// before
$ ls -l $(which java)
lrwxrwxrwx java -> /opt/jdk11/bin/java  # target deleted
// after
$ sudo ln -sf /usr/lib/jvm/java-21/bin/java /usr/local/bin/java
Defensive patterns

Strategy: try-catch

Validate before calling

import subprocess
def java_probe_ok(java_exe: str) -> bool:
    try:
        r = subprocess.run([java_exe, "-XshowSettings:properties", "-version"],
                           capture_output=True, text=True, timeout=15)
        return r.returncode == 0 and "java.home" in (r.stderr + r.stdout)
    except (OSError, subprocess.TimeoutExpired):
        return False

Type guard

def is_runnable_java(p: str) -> bool:
    return os.path.isfile(p) and os.access(p, os.X_OK)

Try / catch

try:
    ls = start_jdtls()
except SolidLSPException as e:
    if "Failed to run" in str(e) and "-XshowSettings" in str(e):
        fix_java_binary_permissions_or_path()
        ls = start_jdtls()
    else:
        raise

Prevention

When it happens

Trigger: _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.

Common situations: 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.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/52f90efab18108df. Report an issue: GitHub.