Search code examples
javagradleminecraftminecraft-fabric

Can't run ./gradlew genSources


I'm following a tutorial to make a Fabric mod for Minecraft. I'm trying to run genSources but it gives this error.

PS C:\Users\Voxe\Minecraft\Plugins\AllianceClient> ./gradlew genSources

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Voxe\Minecraft\Plugins\AllianceClient\build.gradle' line: 2

* What went wrong:
An exception occurred applying plugin request [id: 'fabric-loom', version: '1.2-SNAPSHOT']
> Failed to apply plugin 'fabric-loom'.
   > You are using an outdated version of Java (8). Java 17 or higher is required.
     The JAVA_HOME environment variable is currently set to (C:\Program Files\Java\jdk1.8.0_221).

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

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

My JAVA_HOME is not set to jdk1.8.0_221, but jdk-17.0.1, and so is the variable in the PATH.


Solution

  • I found out how to fix this:

    You can set an environment variable in PowerShell (there's a difference in the environment variables between the PowerShell in the project and command prompt for some reason) with $env:VARIABLE_NAME='C:\path\to\folder and verify that it's correct with dir env:.