cocolabs / pz-zdoc

ZomboidDoc is a Lua library compiler for Project Zomboid.
GNU General Public License v3.0
23 stars 9 forks source link

PZ Version 41.71 compilation issues due to pz files having been compiled by a more recent version of Java #82

Open Alpiyidir opened 2 years ago

Alpiyidir commented 2 years ago

Won't work, if I try to run it with jdk 17 different errors pop up.

Exception in thread "main" java.lang.UnsupportedClassVersionError: zombie/core/Core has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:756) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.springframework.util.ClassUtils.forName(ClassUtils.java:284) at io.cocolabs.pz.zdoc.util.Utils.getClassForName(Utils.java:101) at io.cocolabs.pz.zdoc.Main.main(Main.java:99)

Execution failed for task ':zomboidVersion'.

Process 'command 'C:\Users\Solak.gradle\jdks\jdk8u332-b09\bin\java.exe'' finished with non-zero exit value 1

Alpiyidir commented 2 years ago

07/06/22 (for version 41.71, using IntelliJ IDEA)

I'll post my solution here incase it helps anybody with the same issue:

  1. Making sure gradle doesn't fail to build as the original link used here no longer works Edit line 5 in distribution.gradle to apply from: 'https://gist.githubusercontent.com/matshou/540f0c59633cd0f857a74848be7ccfc3/raw/changelog.gradle' (You can also remove line 4 and 5 to exclude using changelog.gradle but changing it to this link will make the program run as intended)

  2. Changing the gradle version to be compatible with JDK 17 Go to gradle/wrapper and open gradle-wrapper.properties Set the distributionUrl to https://services.gradle.org/distributions/gradle-7.4.2-all.zip

  3. Changing the Gradle JVM to version 17 (Any version >17 should work) Go to File/Settings on the IntelliJ settings. Navigate to Build, Execution, Deployment/Build Tools/Gradle Set "Gradle JVM" to JDK 17

  4. Setting project SDK to version 17 Go to File/Project Structure/Project Set "Project SDK" to the same version as your Gradle JDK

Now you should be able to run the code and use anything you need, it will take a second to start as it will first download a newer version of gradle.

jerohero commented 1 year ago

07/06/22 (for version 41.71, using IntelliJ IDEA)

I'll post my solution here incase it helps anybody with the same issue:

  1. Making sure gradle doesn't fail to build as the original link used here no longer works Edit line 5 in distribution.gradle to apply from: 'https://gist.githubusercontent.com/matshou/540f0c59633cd0f857a74848be7ccfc3/raw/changelog.gradle' (You can also remove line 4 and 5 to exclude using changelog.gradle but changing it to this link will make the program run as intended)
  2. Changing the gradle version to be compatible with JDK 17 Go to gradle/wrapper and open gradle-wrapper.properties Set the distributionUrl to https://services.gradle.org/distributions/gradle-7.4.2-all.zip
  3. Changing the Gradle JVM to version 17 (Any version >17 should work) Go to File/Settings on the IntelliJ settings. Navigate to Build, Execution, Deployment/Build Tools/Gradle Set "Gradle JVM" to JDK 17
  4. Setting project SDK to version 17 Go to File/Project Structure/Project Set "Project SDK" to the same version as your Gradle JDK

Now you should be able to run the code and use anything you need, it will take a second to start as it will first download a newer version of gradle.

Also change

toolchain {
  languageVersion = JavaLanguageVersion.of(8)
}

to

toolchain {
  languageVersion = JavaLanguageVersion.of(17)
}

In build.gradle and zdoc.gradle to avoid issues during setupWorkspace

AlecSanderB commented 1 year ago

07/06/22 (for version 41.71, using IntelliJ IDEA) I'll post my solution here incase it helps anybody with the same issue:

  1. Making sure gradle doesn't fail to build as the original link used here no longer works Edit line 5 in distribution.gradle to apply from: 'https://gist.githubusercontent.com/matshou/540f0c59633cd0f857a74848be7ccfc3/raw/changelog.gradle' (You can also remove line 4 and 5 to exclude using changelog.gradle but changing it to this link will make the program run as intended)
  2. Changing the gradle version to be compatible with JDK 17 Go to gradle/wrapper and open gradle-wrapper.properties Set the distributionUrl to https://services.gradle.org/distributions/gradle-7.4.2-all.zip
  3. Changing the Gradle JVM to version 17 (Any version >17 should work) Go to File/Settings on the IntelliJ settings. Navigate to Build, Execution, Deployment/Build Tools/Gradle Set "Gradle JVM" to JDK 17
  4. Setting project SDK to version 17 Go to File/Project Structure/Project Set "Project SDK" to the same version as your Gradle JDK

Now you should be able to run the code and use anything you need, it will take a second to start as it will first download a newer version of gradle.

Also change

toolchain {
  languageVersion = JavaLanguageVersion.of(8)
}

to

toolchain {
  languageVersion = JavaLanguageVersion.of(17)
}

In build.gradle and zdoc.gradle to avoid issues during setupWorkspace

And change it.javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(10) } to it.javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(17) } in zomboid.gradle

Also, if it complains about a missing mod version, add the line "modversion=0.1.1" in mod.info