BrightSpots / rcv

Ranked Choice Voting Universal Tabulator
Mozilla Public License 2.0
70 stars 19 forks source link

Will not run with JDK 22 under Windows 11 #814

Open davidlbangs opened 4 months ago

davidlbangs commented 4 months ago

I installed JDK 22 because JDK 20 is not available.
PS E:\devdrive\rctab\rcv> java -version openjdk version "22" 2024-03-19 OpenJDK Runtime Environment (build 22+36-2370) OpenJDK 64-Bit Server VM (build 22+36-2370, mixed mode, sharing)

I cloned the respository and typed ./gradlew run in the rcv folder as instructed.

PS E:\devdrive\rctab\rcv> ./gradlew run Downloading https://services.gradle.org/distributions/gradle-8.1.1-bin.zip ...........10%............20%............30%............40%............50%............60%............70%............80%...........90%............100%

Welcome to Gradle 8.1.1!

Here are the highlights of this release:

For more details see https://docs.gradle.org/8.1.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

BUILD FAILED in 14s

That's it. I realize this may not actually be a problem with the project.

AI says: The error message "Unsupported class file major version 66" suggests that there is a mismatch between the Java version used to compile the Gradle script and the Java version being used to run Gradle.

However, since it says JDK 20 or later, and JDK 20 itself isn't availble, I'll wait for clarification.

davidlbangs commented 4 months ago

I tried again with JDK 21. Very similar error:

PS E:\devdrive\rctab\rcv> ./gradlew run Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

FAILURE: Build failed with an exception.

BUILD FAILED in 3s PS E:\devdrive\rctab\rcv>

yezr commented 4 months ago

Why is JDK 20 not available for you? Can you get it from here? https://jdk.java.net/archive/

davidlbangs commented 4 months ago

OK, so though https://jdk.java.net/archive/ is still there, the main download page doesn't have JDK 20 and there is no installer for this version. So, I unzipped it into C:/Program Files/Java, so I now have jdk-20 and jdk-21 folders. I set JAVA_HOME to C:/Program Files/Java/jdk-20. Java.exe lives under Common Files/Oracle Java and has to pick which JDK to use. It is picking version 21 in spite of JAVA_HOME. On the Internet, I am told to use a "Configure Java" program, but I don't have one.

PS C:\Users\david> $env:java_home C:\Program Files\Java\jdk-20 PS C:\Users\david> java -version java version "21.0.2" 2024-01-16 LTS

If each Java program works with exactly one specific version of Java, then people need to have multiple JDKs. Yet, there seems no documented way to switch between Java Versions under Windows?

I stand by my bug report, because people are actually suppose to run RCTab, and the instructions provided are insufficient.

davidlbangs commented 4 months ago

I found a solution for changing Java versions: https://github.com/FelixSelter/JEnv-for-Windows/

jenv can be configured to change the global java version, but setting it up requires multiple steps. However, by setting my global Java Version to jdk20, I can run RCTab.

yezr commented 4 months ago

We can update docs to be more specific. I see in the readme where it can be more clear.

davidlbangs commented 4 months ago

Or it can work with a long term support version of Java that will continue to have an installer.

"Oracle will designate only certain releases as Long-Term-Support (LTS) releases. Java SE 8, 11, 17 and 21 are LTS releases"

If each user needs to find the archives and unzip version 20 and set up a bunch of environment and config files to make it work manually, making the app a little less version dependent would be less work.

artoonie commented 4 months ago

I think the solutions here would be:

  1. Have a "develop" release posted with regularly-updating executables (exe, dmg, and deb)
  2. Update the README to specify an exact JDK rather than "20 or later"

This solves both problems, it would seem.

nurse-the-code commented 2 months ago

I had a similar problem with Java 22 on MacOS. I would echo @artoonie suggestion of updating the README to recommend a specific JDK (or at least version).

I would also elevate @davidlbangs's suggestion of using jEnv. On a previous development team, it helped us solve some recurring issues surrounding different developers using different versions of Java. I can also vouch for it working on MacOS (M1/Apple Silicon).