20 hours ago
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?
incorrect java version
28 hours ago
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 messages
systemctl status jenkins.service
Nov 13 09:35:43 tattve jenkins: Found an incorrect Java version
Nov 13 09:35:43 tattve jenkins: Java version found:
Nov 13 09:35:43 tattve jenkins: openjdk version "220.127.116.11" 2020-11-04
Nov 13 09:35:43 tattve jenkins: OpenJDK Runtime Environment (build 18.104.22.168+1-Ubuntu-0ubuntu1.20.04)
Nov 13 09:35:43 tattve jenkins: OpenJDK 64-Bit Server VM (build 22.214.171.124+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
Nov 13 09:35:43 tattve jenkins: Aborting
Which 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 broad
# Which Java versions can be used to run Jenkins
JAVA_ALLOWED_VERSIONS=( "18" "110" )
# Work out the JAVA version we are working with:
JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*".*/\1\2/p;')
It 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:
JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\([0-9]*\)\.\([0-9]*\)\..*".*/\1\2/p;')
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
30 hours ago
Jenkins work perfectly with the Ubuntu provided openjdk packges. You can even decide which OpenJDK version you prefer:
# headless JRE is enough for Jenkins
$ sudo apt install openjdk-8-jre-headless
# or with JAVA 11
$ sudo apt install openjdk-11-jre-headless
The this post on howto maintain multible Java versions.
There is some very easy documentation on how to install the upstream jenkins Debian packages.
$ wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add
$ sudo bash -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
$ sudo apt update
$ sudo apt-get install jenkins
That should do the trick.
If you are using a packages based Jenkins installation, remove the package with:
$ sudo apt remove jenkins
If you are using the tarball from the Jenkins site, just delete the folder where you installed it.
2 hours ago
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
http://localhost:9090 to start config of jenkins
33 hours ago
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:
sudo apt-get upgrade jenkins
Which properly replaced all the files to the latest version