How to fix jenkins installation error on ubuntu linux

● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2022-11-28 05:07:42 UTC; 8ms ago
Process: 22182 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
Main PID: 22182 (code=exited, status=1/FAILURE)

Nov 28 05:07:42 ip-172-31-19-156 systemd[1]: jenkins.service: Main process exited, code=exited, status=1/FAILURE
Nov 28 05:07:42 ip-172-31-19-156 systemd[1]: jenkins.service: Failed with result ‘exit-code’.
Nov 28 05:07:42 ip-172-31-19-156 systemd[1]: Failed to start Jenkins Continuous Integration Server.
dpkg: error processing package jenkins (–configure):
installed jenkins package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)

suggests that you should read the system logs with the command:

# journalctl -u jenkins

That may tell you that Jenkins is trying to use Java 11 but your system is configured to use Java 8. It may tell you that your system does not have Java installed. It may provide other hints about what is causing the Jenkins service to not start on your machine.

You may also want to read and assure that you follow all the installation instructions.

I have installed java1.8 only, After i put "journalctl -u jenkins " command … i am getting below – Logs begin at Sun 2022-11-27 15:40:45 UTC, end at Mon 2022-11-28 05:17:01 UTC. –
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Starting Jenkins Continuous Integration Server…
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17844]: jenkins: invalid Java version: openjdk version “1.8.0_352”
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17844]: OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17844]: OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Main process exited, code=exited, status=1/FAILURE
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Failed with result ‘exit-code’.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Failed to start Jenkins Continuous Integration Server.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 1.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Stopped Jenkins Continuous Integration Server.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Starting Jenkins Continuous Integration Server…
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17918]: jenkins: invalid Java version: openjdk version “1.8.0_352”
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17918]: OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17918]: OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Main process exited, code=exited, status=1/FAILURE
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Failed with result ‘exit-code’.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Failed to start Jenkins Continuous Integration Server.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 2.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Stopped Jenkins Continuous Integration Server.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Starting Jenkins Continuous Integration Server…
Nov 27 16:12:10 ip-172-31-19-156 jenkins[18065]: jenkins: invalid Java version: openjdk version “1.8.0_352”
Nov 27 16:12:10 ip-172-31-19-156 jenkins[18065]: OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)

The Java requirements page (linked from the installing page) says that you must have Java 11 or Java 17. Java 8 is not supported by recent Jenkins versions

https://www.jenkins.io/doc/administration/requirements/java/

The message “invalid Java version” is telling you that you need a supported version of Java. Jenkins supports Java 11 and Java 17 for new installs. Install and configure Java 11 or Java 17.

1 Like

yes frist remove java-1.8 -->yum remove java-1.8* and install openjdk 11 or 17 this has worked for me

Thank you brothers @MarkEWaite @veereshalladi