Ide scripting console / kotlin / defaultProject / nullPointerException


#1

‘’’
import com.intellij.openapi.project.ProjectManager
val x = ProjectManager.getInstance().defaultProject
‘’’

I’m running the above code in the IDE Scripting Console.

What I expect to happen: I get the defaultProject

What happens: “ProjectManager.getInstance()” throws a NullPointerException

Question: WTF am I doing wrong? How do I get access to the ProjectManager ?

Aside:

I am running this code in a classpath that includes
implementation (“com.intellij:openapi:7.0.3”)


#2
import com.intellij.openapi.ui.Messages
Messages.showInfoMessage("Hello World", "more")

results in:

Exception in thread "main" java.lang.NoSuchMethodError: com.intellij.CommonBundle.getOkButtonText()Ljava/lang/String;
	at com.intellij.openapi.ui.Messages.<clinit>(Messages.java:45)
	at org.jetbrains.kotlin.idea.scratch.generated.ScratchFileRunnerGenerated$ScratchFileRunnerGenerated.generated_get_instance_res0(tmp.kt:8)
	at org.jetbrains.kotlin.idea.scratch.generated.ScratchFileRunnerGenerated.main(tmp.kt:14)