{"record":{"id":"c65e2c5c8428ab99","repo":"hashicorp/nomad","slug":"failed-to-find-java-binary-s","errorCode":null,"errorMessage":"failed to find java binary: %s","messagePattern":"failed to find java binary: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/java/driver.go","lineNumber":452,"sourceCode":"\t\treturn nil, nil, fmt.Errorf(\"task with ID %q already started\", cfg.ID)\n\t}\n\n\tvar driverConfig TaskConfig\n\tif err := cfg.DecodeDriverConfig(&driverConfig); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to decode driver config: %v\", err)\n\t}\n\n\tif err := driverConfig.validate(); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed driver config validation: %v\", err)\n\t}\n\n\tif driverConfig.Class == \"\" && driverConfig.JarPath == \"\" {\n\t\treturn nil, nil, fmt.Errorf(\"jar_path or class must be specified\")\n\t}\n\n\tabsPath, err := GetAbsolutePath(\"java\")\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to find java binary: %s\", err)\n\t}\n\n\targs := javaCmdArgs(driverConfig)\n\n\td.logger.Info(\"starting java task\", \"driver_cfg\", hclog.Fmt(\"%+v\", driverConfig), \"args\", args)\n\n\thandle = drivers.NewTaskHandle(taskHandleVersion)\n\thandle.Config = cfg\n\n\tpluginLogFile := filepath.Join(cfg.TaskDir().Dir, \"executor.out\")\n\texecutorConfig := &executor.ExecutorConfig{\n\t\tLogFile:     pluginLogFile,\n\t\tLogLevel:    \"debug\",\n\t\tFSIsolation: driverCapabilities.FSIsolation == fsisolation.Chroot,\n\t\tCompute:     d.nomadConfig.Topology.Compute(),\n\t}\n\n\tuser := cfg.User","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/java/driver.go#L434-L470","documentation":"StartTask calls GetAbsolutePath(\"java\") to resolve the java executable on the client host's PATH. If java cannot be found, the driver cannot launch the JVM and wraps the lookup error with this message. It indicates the Nomad client environment lacks a usable Java runtime.","triggerScenarios":"Starting a java-driver task on a Nomad client where the 'java' binary is not installed, not on the client's PATH, not in the driver's plugin_dir/allowed binaries, or exists but is not executable.","commonSituations":"Fresh clients provisioned without a JRE/JDK; images where Java was installed for a different user than the Nomad agent runs as; PATH differences between interactive shells and the Nomad service (systemd scrubbing PATH); fat JRE images vs slim ones; upgrading the OS and dropping /usr/bin/java.","solutions":["Install a JRE/JDK on the Nomad client host and confirm 'java -version' works as the user the nomad agent runs as.","Ensure java is on the PATH of the Nomad agent process (systemd: set Environment=PATH=... or use an absolute java path via the image).","If running with containers/chroot, make sure java is inside the chroot/image used for the task.","Restart the Nomad agent after installing Java so the updated PATH is picked up."],"exampleFix":"# before: task fails with 'failed to find java binary: exec: \"java\": executable file not found in $PATH'\n# after (Debian/Ubuntu client)\nsudo apt-get install -y openjdk-17-jre-headless\n# then verify as the nomad agent user\nsudo -u nomad java -version","handlingStrategy":"validation","validationCode":"// shell check to run on every Nomad client before scheduling java tasks\nif ! command -v java >/dev/null 2>&1; then\n  echo \"java binary not found on Nomad client PATH\" >&2\n  exit 1\nfi\njava -version || exit 1","typeGuard":null,"tryCatchPattern":"h, _, err := driver.StartTask(cfg)\nif err != nil && strings.Contains(err.Error(), \"failed to find java binary\") {\n    return fmt.Errorf(\"install a JRE/JDK on the client and ensure 'java' is on the nomad agent's PATH: %w\", err)\n}","preventionTips":["Provision JRE/JDK as part of the client base image.","Verify 'java -version' as the nomad agent user during client bootstrap.","Pin java in the image and re-check after OS upgrades.","If using systemd, explicitly set PATH in the nomad unit's Environment."],"tags":["nomad","java-driver","environment","missing-binary"],"backgroundTag":"command-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}