2

I have a VM with Ubuntu 18.04 with JDK 12 as default java in it. I want to setup a Jenkins server on it and as it do not support JDK 12 yet, i have installed JRE 8 in it to support Jenkins.

How to configure Jenkins such that it will use this JRE8 instead of JDK12??

2 Answers 2

1

After understanding how Jenkins allows us to override configuration and debugging init script, i found multiple ways to tackle this situation.

  1. Override PATH variable in /etc/default/jenkins(I prefer this solution) PATH=<PATH to your JAVA>

  2. Modify PATH variable in /etc/init.d/jenkins(prefix your path to java) PATH=<PATH to your JAVA>:/bin:/usr/bin:/sbin:/usr/sbin

  3. Force Jenkins to use Java that you specify in /etc/init.d/jenkins JAVA='<PATH to your JAVA>/java'

Note: <PATH to your JAVA> is an absolute path to your java location For E.g. 1. /usr/lib/jvm//bin in case of JDK 2. /usr/lib/jvm//jre/bin in case of JRE

0

Since systemd came around, we can override JENKINS_JAVA_CMD in a drop-in file:

/etc/systemd/system/jenkins.service.d/override.conf

[Service]
Environment="JENKINS_JAVA_CMD=/usr/lib/jvm/temurin-17-jdk-amd64/bin/java"

And run:

systemctl daemon-reload
systemctl restart jenkins.service

/etc/default/jenkins and /etc/init.d/jenkins seem to be entirely ignored.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .