Search code examples
javagradlejava-9gradlewminecraft-forge

Gradlew and Java 9 in Cmd :FAILURE: Build failed with an exception


FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '9.0.4'.

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

This is displayed when I'm running in the console (Cmd) :

gradlew setupDecompWorkspace

My gradlewrapper-properties are:

#Wed Jul 02 15:54:47 CDT 2014 
distributionBase=GRADLE_USER_HOME 
distributionPath=wrapper/dists 
zipStoreBase=GRADLE_USER_HOME 
zipStorePath=wrapper/dists 
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip

The problem is clearly Java 9 but I do not know what to do to solve it. Install Java X.X.X or reinstall Java?


Solution

  • You are using gradle 2.0, but support for Java 9 in gradle requires at least gradle 3, and the latest gradle version at the moment is 4.7.

    Normally, you would be able to upgrade your gradle wrapper using

    gradlew wrapper --gradle-version 4.7
    

    But given your current version of the wrapper (2.0) doesn't support Java 9, this won't work.

    As a workaround, you'll need to install gradle so you can use that to upgrade the wrapper. Follow the instructions on https://gradle.org/install/

    Then - assuming gradle is configured on the PATH - use in the root of your project:

    gradle wrapper --gradle-version 4.7
    

    (notice the use of gradle not gradlew)

    If gradle isn't on the PATH use

    <path-to-your-gradle-install>\bin\gradle wrapper --gradle-version 4.7
    

    Afterwards, you can consider to remove/uninstall the gradle installation again.