This is a problem with a solution.
I went back to Jenkins after many years looking for a simple CI/CD tool that I can run locally on my dev Windows machine.
I downloaded the latest LTS version of Jenkins (2.414.2) and the currently supported version of OpenJDK (21), but the windows service fails to start.
Running the war from the command line gave a clue as to why:
Running with Java 21 from C:\Program Files\Java\jdk-21, which is not yet fully supported.
Run the command again with the --enable-future-java flag to enable preview support for future Java versions.
Supported Java versions are: [11, 17]
This is a bit limiting as OpenJDK 17 is deprecated and I'm not keen on having outdated Java binaries installed. Also the Jenkins install page claims to support OpenJDK21, so I'm not sure what's going on with the Windows service (perhaps needs updating).
The Fix
In order to keep the most current JDK and run the Jenkins service, go and edit the file jenkins.xml - typically found here:
C:\Program Files\Jenkins\jenkins.xml
And modify the < arguments > tag by appending the flag --enable-future-java
Your argument tag should look something like this:
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Program Files\Jenkins\jenkins.war" --httpPort=8080 --webroot="%LocalAppData%\Jenkins\war" --enable-future-java </arguments>
Save the file and you should be able to start the service with no issues.
This will hopefully get your Jenkins Service working.
Per Jenkins web site Java 21 is only supported for LTS 2.426.1 (November 2023) and above.
I agree using EOL java is not a good idea. Looks like the parameter "--enable-future-java" has been around a while just for this reason.