IntelliJ Platform SDK DevGuide

Edit page


Every project uses a Software Development Kit (SDK). For Java projects, the SDK is referred to as the JDK (Java Development Kit). The SDK determines which API library is used to build the project. If your project is multi-module, the project SDK by default is common for all modules within the project. Optionally, you can configure individual SDKs for each module. For more information about SDKs, see SDK in the IntelliJ IDEA Web Help.

Getting project SDK information

Main information about the project SDK can be accessed via like the following example shows

Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();

Getting and setting project SDK attributes

  • To get the project level SDK

    Sdk projectSDK = ProjectRootManager.getInstance(project).getProjectSdk();
  • To get the project level SDK name:

    String projectSDKName = ProjectRootManager.getInstance(project).getProjectSdkName();
  • To set the project level SDK:

    ProjectRootManager.getInstance(project).setProjectSdk(Sdk jdk);
  • To set the project level SDK name:

    ProjectRootManager.getInstance(project).setProjectSdkName(String name);

See the following code sample to get more familiar with SDK manipulation tool set.

Working with your own SDK

To create your own SDK, You need to create a class extends SdkType, leave saveAdditionalData blank, and register it in the com.intellij.sdkType extension point.

To make your SDK settings persistant, you should override setupSdkPaths and save your settings by modificator.commitChanges():

@Override public boolean setupSdkPaths(@NotNull Sdk sdk, @NotNull SdkModel sdkModel) { SdkModificator modificator = sdk.getSdkModificator(); modificator.setVersionString(getVersionString(sdk)); modificator.commitChanges(); // save return true; }

To let user select an SDK, see ProjectJdksEditor.

However, it is not recommended to use “SDK” in non-IDEA IDEs. Although “SDK” is available in most JB products, ProjectJdksEditor is IntelliJ-specific, making the operation around “SDK” difficult. The most recommended way of managing your “SDK” settings is to create a CustomStepProjectGenerator implementation and save settings in a PersistentStateComponent.

Last modified: 12 March 2019