I am trying to install Jenkins on Amazon Linux instance and getting the error:
Job for jenkins.service failed because the control process exited with error code. See “systemctl status jenkins.service” and “journalctl -xeu jenkins.service” for details. Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /usr/lib/systemd/system/jenkins.service. ● jenkins.service - Jenkins Continuous Integration Server Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; preset: disabled) Active: activating (start) since Wed 2024-04-17 07:50:35 UTC; 4ms ago Main PID: 27761 (jenkins) Tasks: 2 (limit: 1114) Memory: 532.0K CPU: 3ms CGroup: /system.slice/jenkins.service ├─27761 /bin/sh /usr/bin/jenkins └─27768 “[jenkins]”
I did uninstall java 11 using
yum remove java*
and installed java 17 using
sudo dnf install java-17-amazon-corretto -y
and
Once I run this command journalctl -u jenkins I get the below details:
Starting jenkins.service - Jenkins Continuous Integration Server…
Running with Java 11 from /usr/lib/jvm/java-11-amazon-corretto.x86_64, which is older
Supported Java versions are: [17, 21]
See https://jenkins.io/redirect/java-support/ for more information.
jenkins.service: Main process exited, code=exited, status=1/FAILURE
jenkins.service: Failed with result ‘exit-code’.
Failed to start jenkins.service - Jenkins Continuous Integration Server.
jenkins.service: Scheduled restart job, restart counter is at 1.
Stopped jenkins.service - Jenkins Continuous Integration Server.
It looks like you still have a JDK 11 installed, and that is the one that is used for Jenkins.
It also looks like you’re running the weekly version of Jenkins, which now needs a JDK17 to work.
To get all the JDK and JRE versions installed under Amazon Linux, you can use the alternatives command to list all the installed Java alternatives. Additionally, you can use the java -version and javac -version commands to check the currently active JRE and JDK versions, respectively.
To make JDK 17 the default JDK used on Amazon Linux, you can use the alternatives command to configure the default version of Java. This involves setting the default for both java (which affects the JRE) and javac (which affects the JDK).
Here’s a step-by-step guide in pseudocode:
List all installed Java alternatives:
Use alternatives --display java to list all Java installations and their paths.
Use alternatives --display javac to list all JDK installations and their paths.
Set JDK 17 as the default:
Identify the installation path of JDK 17 from the list obtained in step 1.
Use sudo alternatives --config java and follow the prompt to select JDK 17 for the JRE.
Use sudo alternatives --config javac and follow the prompt to select JDK 17 for the JDK.