Intellij idea says Java Home is Different

2019-01-22 07:36发布

The newly created daemon process has a different context than expected. It won't be possible to reconnect to this daemon. Context mismatch:
Java home is different.

Wanted:DefaultDaemonContext[uid=null,javaHome=/home/administrator/Downloads/idea-IU-145.1617.8/jre,daemonRegistryDir=/home/administrator/.gradle/daemon,pid=11963,idleTimeout=null,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=IN,-Duser.language=en,-Duser.variant]

Actual: DefaultDaemonContext[uid=4839fb8c-418b-4666-9a66-40a60133958a,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/home/administrator/.gradle/daemon,pid=15202,idleTimeout=60000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=IN,-Duser.language=en,-Duser.variant]

6条回答
走好不送
2楼-- · 2019-01-22 07:42

Fwiw - Had a similar thing after, and just reopening the project by picking the build.gradle file fixed it. (Also, done brew cask install java which placed jdk 10 in the default path)

查看更多
Luminary・发光体
3楼-- · 2019-01-22 07:48

Worked like magic.. have been struggling for 2 days now. org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home in ~/.gradle/gradle.properties

查看更多
爷、活的狠高调
4楼-- · 2019-01-22 07:54

IntelliJ broke when I copied tools.jar to a jre/lib, attempting to make hot attach work.

查看更多
The star\"
5楼-- · 2019-01-22 07:59

Though I did not find the root cause where the different javaHomes have been taken from, at least I found a workaround that worked for me:

Try setting the following in your gradle.properties (either in $HOME/.gradle/ or in your project build dir):

org.gradle.java.home=/usr/lib/jvm/java-8-openjdk-amd64
查看更多
The star\"
6楼-- · 2019-01-22 08:00

Be sure to check and correct JDK version in these 3 places:

  1. Check Preferences -> Build,... -> Build Tools -> Gradle -> Gradle JVM: Gradle Preferences
  2. Check Project Structure -> Project Settings -> Project -> Project SDK:
    Project
  3. Check Project Structure -> Platform Settings -> SDKs: SDKs

Fixing gradle.properties is a dirty workaround. Better fix this at the IDE level.

查看更多
冷血范
7楼-- · 2019-01-22 08:00

I ran into the same problem. This answer helped me.

Solution: In the bin folder of IntelliJ where you have it installed, run idea64.exe not idea.exe.

查看更多
登录 后发表回答