How to use JDK 8 in the latest version of Jenkins

I’m currently using JDK 8 and if I update to the latest Jenkins,
it’s automatically building to JDK 11 due to maven plugin on jenkins servers.
Is there a way to prevent this and keep using JDK 8?

You need to add an agent that has Java 8 installed. (You should never run builds on the controller itself.)

Thank you for your response,

I wonder what is the difference between applying another JDK through agent and applying JDK directly to be used for the project in Job configuration - General section.

As far as I know, when you apply a JDK through an agent, you’re specifying the Java Development Kit (JDK) that the agent should use to run Jenkins and its jobs.
This JDK is used for all jobs that run on this agent unless a job specifies a different JDK in its configuration.

On the other hand, when you apply a JDK directly in the job configuration under the General section, you’re specifying the JDK that this particular job should use.
This JDK is used only for this job and overrides the JDK specified at the agent level.

So, the main difference is the scope: the JDK specified at the agent level applies to all jobs running on that agent, while the JDK specified at the job level applies only to that job.
This allows you to use different versions of the JDK for different jobs, if necessary. :person_shrugging: