JetBrains/intellij-community · error · CantRunException

Cannot generate JavaDoc - no Java SDK is configured for the

Error message

Cannot generate JavaDoc - no Java SDK is configured for the project. Please specify a Java SDK in Settings | Project Structure.

What it means

Before launching javadoc, JavadocGeneratorRunProfile builds the command line: it resolves the project SDK and asks the JavaSdkType for its bin path. If there is no SDK at all, or the SDK is not a JavaSdkType, binPath is null and CantRunException('Cannot generate JavaDoc - no Java SDK is configured...') aborts the run. The message directs the user to Settings | Project Structure because the Tools | Generate JavaDoc action has no JDK to take the javadoc executable from.

Source

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

            }
          }
        }
      });
      return handler;
    }

    private GeneralCommandLine createCommandLine() throws ExecutionException {
      GeneralCommandLine cmdLine = new GeneralCommandLine();
      Sdk jdk = getSdk(myProject);
      setExecutable(jdk, cmdLine);
      setParameters(jdk, cmdLine);
      return cmdLine;
    }

    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());

View on GitHub (pinned to be881553f2)

Solutions

  1. Open File | Project Structure | Project and set a valid Project SDK (a full JDK, not a JRE).
  2. Verify the JDK path still exists on disk (invalid paths show red); re-point or re-add the JDK if the installation moved.
  3. For Gradle/Maven projects, ensure the imported JDK resolved (Gradle JVM setting) so the module SDKs are valid, then re-run generation.
Defensive patterns

Strategy: validation

Validate before calling

// Before running javadoc generation:
Sdk sdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (sdk == null || !(sdk.getSdkType() instanceof JavaSdkType)) {
  Messages.showWarningDialog("Set a Project SDK (full JDK) before generating Javadoc", "No JDK");
  return;
}

Prevention

When it happens

Trigger: Running Tools | Generate JavaDoc in a project with no Project SDK defined, or with a non-Java SDK (e.g. Python/Android-only setup) selected; or the module SDK chain resolves to null.

Common situations: Newly imported projects where the SDK was never set; CI-generated projects missing .idea SDK bindings; projects opened after the configured JDK path was deleted or the SDK name became unresolved.

Related errors


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