Test Runner: Java Compiler was not found in classpath
I haven't seen anything recent in the forums about this so maybe this is new again.
My Setup:
- IDEA 2017.1.5 managed by ToolBox
- Java 1.8
- Gradle Build - Single Project
- Spock Unit Tests
When I attempt to run the unit test inside IDEA (I believe this is called the JUnit Runner), I get the Message that you see at the bottom of this post. In Project Structure both the _main and _test modules have a valid Module SDK. I've invalidated caches/restarted, gradle clean, removed .gradle, restarted and did a little dance but all to no avail.
If I run the tests using gradle test, they run fine and and I see the results in IDEA but it's so much slower.
Any insights would be appreciated.
Error:java: System Java Compiler was not found in classpath:
java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.jetbrains.jps.builders.impl.java.JavacCompilerTool.createCompiler(JavacCompilerTool.java:70)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:63)
at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:483)
at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:339)
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:256)
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:214)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1263)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:940)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1012)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:903)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:736)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:384)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:192)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:236)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
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:748)
Please sign in to leave a comment.
Try to reinstall JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html, delete the existing JSDK configuration in IntelliJ IDEA and configure a new one. Make sure your project and modules are set to use this new JDK.
Rebuild the project.
If it doesn't help, please file a bug at https://youtrack.jetbrains.com/issues/IDEA with the following attached:
https://youtrack.jetbrains.com/issue/IDEA-175762
For anyone else that runs into this... my project was pointing to an OpenJDK installation instead of an Oracle JDK. Switching to the Oracle JDK resolved the issue.