FAILURE: Build failed with an exception IntelliJ

Can anyone help me understand why I receive the following error when running “gradlew run” from the terminal in IntelliJ IDEA?

AILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:compileJava’.

Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

  • Get more help at

1 actionable task: 1 executed

I am using Java 9 and I can run javac -version from the terminal successfully.

I am using IntelliJ 2018.1.3.