compileReleaseKotlin fails with java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context

家住魔仙堡 提交于 2019-11-27 09:04:36

OK, problem is with JDK, I was using Open JDK 8 and it was missing tools.jar for some reason, I switched to Oracle JDK and now it works like a charm!

I solved it only by replacing in build.gradle this

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.30"

with this:

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.30"

I got this exact issue on Windows when the JDK bin directory was not in my PATH.

The process is documented here: http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html#path

If you have windows, change your PATH so that it includes C:\Program Files\Java\jdk1.8.0_151\bin instead of C:\ProgramData\Oracle\Java\javapath

Yeah, it might break in an update or whatever, but considering that an update broke my machine... At least you're in control now.

My guess is that C:\ProgramData\Oracle\Java\javapath points to the non-jdk jre, thus failing to find javac-specific jars.

I've figured out that on CentOS 7 this error cab be caused by absence of right java package. So, instead of yum install java-1.8.0-openjdk I used yum install java-1.8.0-openjdk-devel and it worked. On Ubuntu there is no devel packege, but I hope this answer helps anyway.

The problem is due to C:\ProgramData\Oracle\Java\javapath which points to the non-jdk jre, thus failing to find javac-specific jars. Please remove it with C:\Program Files\Java\jdk1.8.0_171\bin (for e.g.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!