Skip to content

Commit 3bdb4d5

Browse files
Add setjava tag (#191)
For all the places the Java version needs to be set in a project
1 parent 60156d1 commit 3bdb4d5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tags/faq/setjava.ytag

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
type: text
2+
3+
---
4+
5+
To change the Java version you're developing for, you need to set the version in several places. This uses Java 21 as an example.
6+
```diff
7+
// build.gradle
8+
tasks.withType(JavaCompile).configureEach {
9+
+ it.options.release = 21
10+
}
11+
12+
java {
13+
+ sourceCompatibility = JavaVersion.VERSION_21
14+
+ targetCompatibility = JavaVersion.VERSION_21
15+
}
16+
```
17+
```diff
18+
// modid.mixins.json
19+
// Also in modid.client.mixins.json if you're using split sources
20+
{
21+
+ "compatibilityLevel": "JAVA_21"
22+
}
23+
```
24+
```diff
25+
// fabric.mod.json
26+
{
27+
"depends": {
28+
+ "java": ">=21"
29+
}
30+
}
31+
```
32+
Finally, in IntelliJ:
33+
File | Project Structure | Project Settings | Project | SDK -> Set to a Java 21 JDK
34+
File | Project Structure | Project Settings | Project | Language level -> Set to SDK default (or 21)
35+
File | Settings | Build, Execution, Deployment | Build Tools | Gradle -> Set Gradle JVM to Project SDK (or a Java 21 JDK)

0 commit comments

Comments
 (0)