I tried to install latest stable Jenkins version which supports Java 11. So after installing Java 11(JDK) I got the error from Jenkins that incorrect java version was found.
So uninstalled the Java 11 and tried to install Java 8. While installing java 8, the Jenkins messages incorrect java version
repeatedly was coming. So I completely removed both Java 11(JDK) and Java 8(JDK) and made sure no folders are there in /usr/bin
and /usr/lib/jvm
for both java 11 and java 8. When I installed java 8 the system says JDK 8 installed but im not able to find any java version in my system. Why?
- How to set up the JDK 8 for the Jenkins and make it working? Where to find java version?
- How to remove Jenkins completely from the system if I need to install everything from scratch? Or any way to reset the Linux to a previous state (before java and Jenkins installed)
- How to have/maintain both JDK8 and JDK11 in the system?
I've just encountered this problem, and it actually looks like an issue in
/etc/init.d/jenkins
testing for the Java version. I just posted a solution here: https://dorian.fraser-moore.com/works/5054500/ubuntu-and-jenkins-found-an-incorrect-java-version , sharing below for those who find this question as first google hit.Following a recent update to my Ubuntu 20.04.1 LTS dev server my installation of Jenkins stopped running on boot. Checking
systemctl status jenkins.service
returned back this set of messagesWhich seemed odd, as jenkins support Java 11 and openJDK, indeed I'd been running that before.
Digging around a bit I noticed the init script in
/etc/init.d/jenkins
that the script, at lines 56-60, was using SED to extract the version from the java - version command into a numeric value, but the regular expression was a bit to broadIt turns out this last line was setting JAVA_VERSION to 11.09 which doesn't match anything in JAVA_ALLOWED_VERSION. I could add 11.09 to JAVA_ALLOWED_VERSIONS to make it run, but a better fix seem to be to fix that permissive sed line. Changing it to:
Did the job. It might help someone else.
[Due Diligence Edit]
It looks like someone has already made a PR for a fix: https://github.com/jenkinsci/packaging/pull/198
Jenkins required java version
Jenkins work perfectly with the Ubuntu provided
openjdk
packges. You can even decide which OpenJDK version you prefer:Maintain multible Java version in Ubuntu
The this post on howto maintain multible Java versions.
Install Jenkins (as Debian package from jenkins.io)
There is some very easy documentation on how to install the upstream jenkins Debian packages.
That should do the trick.
Remove Jenkins
If you are using a packages based Jenkins installation, remove the package with:
If you are using the tarball from the Jenkins site, just delete the folder where you installed it.
Jenkins requires Java 8 jdk to be installed. Check your java version by command $ java -version If you have more than one java installed on your machine use the command $ sudo update-alternatives --config java This will provide a list of java versions on your machines. Use the comands to install jenkins $ sudo apt update $ sudo apt install jenkins
To change the port number to say 9090 please edit using sudo $ sudo vim /etc/default/jenkins 8080 is the most commonly used port Find 8080 and change to 9090 Save the file using :wq for Vim editor Open browser http://localhost:9090 to start config of jenkins
I got this error after upgrading java from 8 to 11; because I had manually upgraded my jenkins on ubuntu by swapping in the new war. So, my old install had persisted the
/etc/init.d/jenkins
file with the bug.For me the fix was as simple as running the proper apt-get update:
Which properly replaced all the files to the latest version