Builds failing after upgrade Jenkins with Java

Hello Everyone,

We have a Jenkins server which we have recently upgraded to Jenkins 2.401.1 and also OS Debian upgrade to 11. After we have upgraded Jenkins some of our build which were being compiled on Java 8 is now failing as we have upgraded the java version to 11 as-well since Debian 11 doesn’t support Java 8 what are the options we have so that our builds can run successfully which were being compiled on Java 8?

The future-proof solution would be to update your build tool chain to support compiling on more recent Java versions than 8.
Keep in mind: Compiling on Java version xy doesn’t mean you automatically target xy. You certainly can compile something on Java 20 and target Java 8.

Alternatively, you can install Java 8 on your agent, for now, and reference it in your pipelines.

Thanks for your response, I tried to compile using Java11 through build tool chain targeting java 8 but that didn’t seem to work as Java doesnt support backward compatibility. Plus Debian 11 doesnt have support for Java 8 so that is also not an option.

Java is very backwards compatible, but byte code produced on newer versions is not, unless you add the release flag to javac.
Depending on your project setup and tooling, the steps to take can vary.

As a working example in Jenkins, we’re using maven’s release option, parsing the flag for us, to compile on Java 11 targeting Java 8 (in very rare occasions).
The same exists for gradle too, covering almost the entire maven ecosystem.

If that’s supposed to mean, that the default package list does no longer contain Java 8, I’d recommend using another one. The adoptium working group does publish their temurin-8 builds for debian at packages.adoptium.net.
Alternatively, you may download a generic openjdk archive and invoke the java binary directly.

(Or even more future-proof, moving on to Java 11 and beyond :rocket:)

1 Like

default package list does no longer contain Java 8, I’d recommend using another one

Like this one:

mad@shuttle:~$ cat /etc/debian_version 
11.7
mad@shuttle:~$ /usr/lib/jvm/java-8-openjdk-amd64/bin/java -version
openjdk version "1.8.0_332"
OpenJDK Runtime Environment (build 1.8.0_332-8u332-ga-1~deb9u1-b09)
OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode)
mad@shuttle:~$ dpkg -S /usr/lib/jvm/java-8-openjdk-amd64/bin/java
openjdk-8-jre-headless:amd64: /usr/lib/jvm/java-8-openjdk-amd64/bin/java
mad@shuttle:~$ apt-cache policy openjdk-8-jre-headless:amd64
openjdk-8-jre-headless:
  Installed: 8u332-ga-1~deb9u1
  Candidate: 8u332-ga-1~deb9u1
  Version table:
 *** 8u332-ga-1~deb9u1 500
        500 http://archive.debian.org/debian-security stretch/updates/main amd64 Packages
        100 /var/lib/dpkg/status
     8u252-b09-1~deb9u1 500
        500 http://archive.debian.org/debian stretch/main amd64 Packages
mad@shuttle:~$
1 Like

Also: org.jenkinsci.plugins.workflow.actionsjava.lang.NoSuchMethodError: No such DSL method ‘tools’ found among steps java 8 tools

I mentioned like this in my jenkins file but still giving above error

node (label: ‘jenkins-agent-small’){
tools {
jdk ‘java-8’
}
checkout scm