我正在按照教程为 Minecraft 制作 Fabric mod。我正在尝试运行 genSources 但出现此错误。
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
我的
JAVA_HOME
不是设置为jdk1.8.0_221
,而是jdk-17.0.1
,PATH中的变量也是如此
我找到了解决这个问题的方法:
您可以使用
$env:VARIABLE_NAME='C:\path\to\folder
在 PowerShell 中设置环境变量(由于某些原因,项目中的 PowerShell 和命令提示符之间的环境变量存在差异),并使用 dir env:
验证其是否正确。