Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the reason for "Error:Cannot determine Java VM executable in selected JDK"?

I am using IntelliJ IDEA 13.1.4 and also tried the latest release 14.

Running SBT I get the following error:

Error:Cannot determine Java VM executable in selected JDK

I have JDK 1.7 installed on my machine and on PATH.

In the logs (~/Library/Logs/IntelliJIdea14/idea.log on MacOS) there's the following stack trace:

2014-11-03 11:22:05,054 [4896641]   WARN - nal.AbstractExternalSystemTask - Cannot determine Java VM executable in selected JDK
com.intellij.openapi.externalSystem.model.ExternalSystemException: Cannot determine Java VM executable in selected JDK
    at org.jetbrains.sbt.project.SbtExternalSystemManager$$anonfun$10.apply(SbtExternalSystemManager.scala:97)
    at org.jetbrains.sbt.project.SbtExternalSystemManager$$anonfun$10.apply(SbtExternalSystemManager.scala:97)
    at scala.Option.getOrElse(Option.scala:120)
    at org.jetbrains.sbt.project.SbtExternalSystemManager$.executionSettingsFor(SbtExternalSystemManager.scala:96)
    at org.jetbrains.sbt.project.SbtExternalSystemManager$$anonfun$getExecutionSettingsProvider$1.apply(SbtExternalSystemManager.scala:54)
    at org.jetbrains.sbt.project.SbtExternalSystemManager$$anonfun$getExecutionSettingsProvider$1.apply(SbtExternalSystemManager.scala:54)
    at org.jetbrains.sbt.package$$anon$3.fun(package.scala:29)
    at org.jetbrains.sbt.package$$anon$3.fun(package.scala:28)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.getExecutionSettings(ExternalSystemApiUtil.java:590)
    at com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager.a(ExternalSystemFacadeManager.java:201)
    at com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager.a(ExternalSystemFacadeManager.java:178)
    at com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager.doInvoke(ExternalSystemFacadeManager.java:133)
    at com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager$MyHandler.invoke(ExternalSystemFacadeManager.java:270)
    at com.sun.proxy.$Proxy57.getResolver(Unknown Source)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:475)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$1.run(ExternalSystemUtil.java:543)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:609)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$7.run(ProgressManagerImpl.java:410)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$3.run(ProgressManagerImpl.java:194)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.a(ProgressManagerImpl.java:281)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:233)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:181)
    at com.intellij.openapi.application.impl.ApplicationImpl$10$1.run(ApplicationImpl.java:640)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)

What can be the reason for this?

like image 324
Zuriar Avatar asked Aug 08 '14 10:08

Zuriar


3 Answers

You should be able to work it around by setting the jdk from the settings not from the open/import project dialog.

From the welcome screen, go to Configure -> Project defaults -> Project structure and add the jdk.

enter image description here

Opening the sbt project should work well then.

Found solution from here

like image 132
Prabu Avatar answered Nov 13 '22 19:11

Prabu


Another way to set JDK is from your current module/project settings (for your current project)

PickOpen Module Settings from project context menu (or default hit F4),
then from left tab select Project and point correct Project SDK on dropdown.

enter image description here

like image 25
michalczukm Avatar answered Nov 13 '22 18:11

michalczukm


The issue is usually caused by a wrong JDK version in ".idea/sbt.xml", e.g.:

<option name="jdk" value="1.7" />

This option is not updated accordingly when the Project SDK is changed, see SCL-10085. If you have the other JDK (1.7 in my example) generally configured, no error will occur, but the Project SDK will silently be changed back. Otherwise, this error occurs.

The problem can easily be resolved by manually editing the value in ".idea/sbt.xml" to the right JDK version.

like image 21
F30 Avatar answered Nov 13 '22 19:11

F30