Question Compile Paper 1.21.4 against java 17

confusedalex

New member
Jan 20, 2022
2
0
1
Is it possible to use java 21 and the newest PaperAPI, but compile to java 17 to achieve backwards compatibility?

Code:
compileJava {
    options.encoding = "UTF-8"
    options.compilerArgs.add("-parameters")
    sourceCompatibility = "17"
    targetCompatibility = "17"
}

compileKotlin {
    compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
}

This works when using the newest SpigotAPI, but I want to migrate to the PaperAPI.
 

MiniDigger

Drunk German 🍺
Staff member
Dec 14, 2021
53
2
26
18
27
Cologne, Germany
benndorf.dev
No, paper API makes use of modern java features and thus requires java 21, in line with vanilla requiring java 21.
I don't understand the need to support java 17 on paper 1.21.4 considering you need 21 to run 1.21.4.
If you want to support older paper versions that did allow running with java 17 then you should depend on the lowest paper API you wanna support (and then you can compile against java 17)
 
  • Like
Reactions: confusedalex

electronicboy

Administrator
Staff member
Dec 11, 2021
297
18
59
28
Paper uses Gradle and publishes metadata, which lets Gradle know that the target should support Java 21, etc. You can disable this configuration by disabling the JVM auto target inside of gradle, not sure what section that was in
as said, running mc 1.21.x requires java 21, and so, the reasons for emitting bytecode for older versions generally makes little sense in the long run, this behavior is unsupported and will likely result in issues, especially when you get into supporting older versions of the game, etc.
 
  • Like
Reactions: confusedalex