How do I get default/pre-installed Java SDK for setting as the project SDK programatically?

Answered

In short what do I pass for 

ProjectRootManager.getInstance(project).setProjectSdk(Sdk) 
0
6 comments
Sdk jdk = IdeSdks.getInstance().getJdk();
1

Related to this question, am I right in thinking that recent versions of IntelliJ automatically set up an SDK for projects to use from the bundled JRE?

0

No, Java Runtime Environment cannot be set as a Java Development Kit.

0

Yes, it can, as long as it includes tools.jar (which the bundled one does).

I ask because in my plugin I actually create an SDK automatically from the bundled JB runtime if the user has no SDK configured, but it seems like that might be redundant in recent IntelliJ versions since it seems that IntelliJ also does that. I just wanted to confirm that I can remove that functionality from my plugin.

1
Sdk jdk = IdeSdks.getInstance().getJdk();
Where do I find this class `IdeSdks` 
It's not included in the tools.jar  FYI: working on IntelliJ IDEA plugin
0

Answered by Yann Cebron on slack for future reference

Use this class to get the list of already available JDKs
com.intellij.openapi.projectRoots.ProjectJdkTable
 
0

Please sign in to leave a comment.