SeleniumHQ/selenium · error · OSError
Can't find java on system PATH. JRE is required to run the S
Error message
Can't find java on system PATH. JRE is required to run the Selenium server
What it means
Raised in `start()` when `self.java_path` is unset AND `shutil.which('java')` returns None, i.e. no `java` binary is discoverable on the system PATH. Running the Selenium server JAR requires a JRE, so without java the process cannot be built. It is an OSError.
Source
Thrown at py/selenium/webdriver/remote/server.py:189
Latest version is downloaded unless specified.
"""
args = ["--grid"]
if version is not None:
args.append(version)
return SeleniumManager().binary_paths(args)["driver_path"]
def start(self):
"""Start the server.
Selenium Manager will detect the server location and download it if necessary,
unless an existing server path was specified.
"""
path = self.download_if_needed(self.version) if self.path is None else self.path
java_path = self.java_path or shutil.which("java")
if java_path is None:
raise OSError("Can't find java on system PATH. JRE is required to run the Selenium server")
command = [
java_path,
"-jar",
path,
"standalone",
"--port",
str(self.port),
"--log-level",
self.log_level,
*self.args,
]
if self.host is not None:
command.extend(["--host", self.host])
host = self.host if self.host is not None else "localhost"
try:View on GitHub (pinned to aa36b38e69)
Solutions
- Install a JRE/JDK (e.g. apt-get install -y default-jre, or a temurin image).
- Ensure java's bin directory is on PATH: `which java` must succeed in the same shell.
- Alternatively set server.java_path to an absolute java binary you have verified exists.
Example fix
# before # (no java installed) server.start() # after (Dockerfile) # RUN apt-get update && apt-get install -y default-jre-headless server.start()
Defensive patterns
Strategy: validation
Validate before calling
import shutil
if server.java_path is None and shutil.which('java') is None:
raise EnvironmentError('java/JRE not installed or not on PATH; install a JRE before start()') Prevention
- Bake a JRE into the deployment image rather than relying on the host.
- Assert `shutil.which('java')` in a startup health check.
When it happens
Trigger: Calling `server.start()` on a host/container that has no JDK/JRE installed, or where java is installed but its bin directory is not on PATH. Also when PATH is overridden/reset in the spawned environment (env setter) to exclude java's location.
Common situations: Minimal Docker images (python:slim) with no JVM. CI runners where java is installed under a toolchain manager (sdkman/asdf) that hasn't been activated for the shell. SSH sessions with a trimmed PATH.
Related errors
- Can't find java executable located at {java_path}
- log_level must be one of: {', '.join(levels)}
- env must be a mapping of environment variables
- Timed out waiting for Selenium server at {self.status_url}
- Selenium server isn't running
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/f6950e4c08968c95.
Report an issue: GitHub.