JetBrains/intellij-community · error · CantRunException

Cannot generate JavaDoc - no javadoc tool found at {0} or {1

Error message

Cannot generate JavaDoc - no javadoc tool found at {0} or {1}. Please specify a valid Java SDK in Settings | Project Structure.

What it means

With a JDK configured, the runner locates the javadoc executable: first <jdk>/bin(javadoc|javadoc.exe), then <jdk-parent>/bin, then <java.home>/../bin. If none exists, CantRunException('javadoc.generate.no.javadoc.tool', binPath, javaHomeBinPath) reports both searched paths. This happens when the 'SDK' is actually a JRE (no javadoc binary), a stripped runtime (some compact JDK distributions omit javadoc), or the SDK home points at the wrong directory.

Source

Thrown at java/java-impl/src/com/intellij/javadoc/JavadocGeneratorRunProfile.java:169

    }

    private void setExecutable(Sdk jdk, GeneralCommandLine cmdLine) throws ExecutionException {
      String binPath = jdk != null && jdk.getSdkType() instanceof JavaSdkType ? ((JavaSdkType)jdk.getSdkType()).getBinPath(jdk) : null;
      if (binPath == null) {
        throw new CantRunException(JavaBundle.message("javadoc.generate.no.jdk"));
      }

      cmdLine.setWorkDirectory((File)null);

      String toolName = SystemInfo.isWindows ? "javadoc.exe" : "javadoc";
      File tool = new File(binPath, toolName);
      if (!tool.exists()) {
        tool = new File(new File(binPath).getParent(), toolName);
        if (!tool.exists()) {
          File javaHomeBinPath = new File(new File(System.getProperty("java.home")).getParent(), "bin");
          tool = new File(javaHomeBinPath, toolName);
          if (!tool.exists()) {
            throw new CantRunException(JavaBundle.message("javadoc.generate.no.javadoc.tool", binPath, javaHomeBinPath));
          }
        }
      }
      cmdLine.setExePath(tool.getPath());

      if (myConfiguration.HEAP_SIZE != null && !myConfiguration.HEAP_SIZE.trim().isEmpty()) {
        String param = JavaSdkUtil.isJdkAtLeast(jdk, JavaSdkVersion.JDK_1_2) ? "-J-Xmx" : "-J-mx";
        cmdLine.getParametersList().prepend(param + myConfiguration.HEAP_SIZE + "m");
      }
    }

    /* http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#runningjavadoc */
    private void setParameters(Sdk jdk, GeneralCommandLine cmdLine) throws CantRunException {
      ParametersList parameters = cmdLine.getParametersList();

      if (myConfiguration.LOCALE != null && !myConfiguration.LOCALE.isEmpty()) {
        parameters.add("-locale");
        parameters.add(myConfiguration.LOCALE);

View on GitHub (pinned to be881553f2)

Solutions

  1. Switch the Project SDK to a full JDK (e.g. via apt install default-jdk, or download a Temurin/Oracle JDK) and confirm <jdk>/bin/javadoc exists.
  2. Verify the SDK home directory: it should be the JDK root containing bin/javac, not the embedded jre/ subfolder.
  3. If you must keep a JRE for running, still register a separate full JDK and select it before generating Javadoc.

Example fix

# before: SDK home points at a JRE
/opt/java/jre-21  (no bin/javadoc)

# after: SDK home points at a full JDK
/opt/java/jdk-21  (bin/javadoc present)
Defensive patterns

Strategy: validation

Validate before calling

Sdk sdk = ProjectRootManager.getInstance(project).getProjectSdk();
String bin = (sdk != null && sdk.getSdkType() instanceof JavaSdkType t) ? t.getBinPath(sdk) : null;
String tool = SystemInfo.isWindows ? "javadoc.exe" : "javadoc";
if (bin == null || !(new File(bin, tool).exists() || new File(new File(bin).getParent(), tool).exists())) {
  Messages.showWarningDialog("Selected SDK has no javadoc tool — use a full JDK", "JRE Instead of JDK");
  return;
}

Prevention

When it happens

Trigger: Project SDK is a JRE or a JRE-style runtime (jlink runtime, some Docker base images, older JetBrains Runtime downloads) — directories that contain java but not bin/javadoc — and Tools | Generate JavaDoc is invoked.

Common situations: Pointing the SDK at a JRE folder; using a custom runtime image; Linux package managers installing 'default-jre' instead of 'default-jdk'; macOS users selecting /Library/Internet Plug-Ins style JRE paths.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/6d4ca8bf8352a1d9. Report an issue: GitHub.