{"record":{"id":"d87690438607f621","repo":"JetBrains/intellij-community","slug":"no-jdk-specified-d87690","errorCode":null,"errorMessage":"No JDK specified","messagePattern":"No JDK specified","errorType":"exception","errorClass":"CantRunException","httpStatus":null,"severity":"error","filePath":"java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java","lineNumber":43,"sourceCode":"import org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.nio.charset.Charset;\nimport java.util.Arrays;\nimport java.util.LinkedHashSet;\nimport java.util.Set;\n\npublic class JavaParameters extends SimpleJavaParameters {\n  private static final Logger LOG = Logger.getInstance(JavaParameters.class);\n  private static final String JAVA_LIBRARY_PATH_PROPERTY = \"java.library.path\";\n\n  public static final String JAVA_ENABLE_PREVIEW_PROPERTY = \"--enable-preview\";\n  public static final DataKey<JavaParameters> JAVA_PARAMETERS = DataKey.create(\"javaParameters\");\n\n  public String getJdkPath() throws CantRunException {\n    final Sdk jdk = getJdk();\n    if (jdk == null) {\n      throw new CantRunException(ExecutionBundle.message(\"no.jdk.specified..error.message\"));\n    }\n\n    final VirtualFile jdkHome = jdk.getHomeDirectory();\n    if (jdkHome == null) {\n      throw new CantRunException(ExecutionBundle.message(\"home.directory.not.specified.for.jdk.error.message\"));\n    }\n    return jdkHome.getPresentableUrl();\n  }\n\n  public static final int JDK_ONLY = 0x1;\n  public static final int CLASSES_ONLY = 0x2;\n  public static final int TESTS_ONLY = 0x4;\n  public static final int INCLUDE_PROVIDED = 0x8;\n  public static final int JDK_AND_CLASSES = JDK_ONLY | CLASSES_ONLY;\n  public static final int JDK_AND_CLASSES_AND_TESTS = JDK_ONLY | CLASSES_ONLY | TESTS_ONLY;\n  public static final int CLASSES_AND_TESTS = CLASSES_ONLY | TESTS_ONLY;\n  public static final int JDK_AND_CLASSES_AND_PROVIDED = JDK_ONLY | CLASSES_ONLY | INCLUDE_PROVIDED;\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java#L25-L61","documentation":"Thrown by JavaParameters.getJdkPath() when the run configuration's JavaParameters has no SDK attached (getJdk() returns null). IntelliJ refuses to build the Java command line because there is no java executable to launch. It is a CantRunException, so the run process aborts before the JVM starts.","triggerScenarios":"Calling JavaParameters.getJdkPath() (directly or via a Java run configuration starter that resolves the JDK path) when setJdk()/configureByModule()/configureByProject() never set an SDK, or the module/project JDK resolved to null (e.g. 'No JDK' project SDK and module inherits SDK).","commonSituations":"Newly created project with no Project SDK configured; run configuration with JDK selector left on '<No JDK>' or a deleted/invalid SDK name; module SDK set to inherit while project SDK is undefined; plugin code building JavaParameters manually without calling configureByModule.","solutions":["Open File > Project Structure > Project and set a valid Project SDK","In the Run/Debug Configuration, set the JRE/JDK field to a concrete SDK instead of '<No JDK>'","Check the module's Dependencies tab (Project Structure > Modules) and set 'Module SDK' explicitly instead of inheriting","If the SDK is defined but broken, remove and re-add it in File > Project Structure > SDKs (point it at a real JDK home)","In plugin code, call parameters.configureByModule(module, JavaParameters.JDK_AND_CLASSES, ...) or verify parameters.getJdk() != null before getJdkPath()"],"exampleFix":"// before\nJavaParameters params = new JavaParameters();\nparams.getClassPath().add(dir);\nString jdkPath = params.getJdkPath(); // CantRunException: No JDK specified\n\n// after\nJavaParameters params = new JavaParameters();\nSdk jdk = ProjectRootManager.getInstance(project).getProjectSdk();\nif (jdk == null) throw new CantRunException(\"No project SDK configured\");\nparams.setJdk(jdk);\nString jdkPath = params.getJdkPath();","handlingStrategy":"try-catch","validationCode":"Sdk jdk = params.getJdk();\nif (jdk == null) {\n  jdk = ProjectRootManager.getInstance(project).getProjectSdk();\n}\nif (jdk == null) {\n  // show SDK picker / log and abort before calling getJdkPath()\n  return;\n}","typeGuard":"static boolean hasJdk(@NotNull JavaParameters params) {\n  return params.getJdk() != null;\n}","tryCatchPattern":"try {\n  String path = params.getJdkPath();\n} catch (CantRunException e) {\n  // surface a 'configure SDK' prompt; do not retry silently\n  Messages.showErrorDialog(project, e.getMessage(), \"Cannot Run\");\n}","preventionTips":["Always run params.configureByModule(...) / configureByProject(...) which sets the SDK from the model","Require a Project SDK in project templates used by your team","Check RunConfiguration templates: leave JRE on 'Project SDK' only when the project defines one"],"tags":["java","run-configuration","jdk","sdk","intellij"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}