Jenkins error "Incorrect Java version" for Java11. After removing Java11 and installing Java8. java is not found anywhere


Answer: 1

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?

  1. How to set up the JDK 8 for the Jenkins and make it working? Where to find java version?
  2. 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)
  3. How to have/maintain both JDK8 and JDK11 in the system?
Added by: Valentin Berge

Answer: 2

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: , 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

Nov 13 09:35:43 tattve jenkins[1038744]: Found an incorrect Java version
Nov 13 09:35:43 tattve jenkins[1038744]: Java version found:
Nov 13 09:35:43 tattve jenkins[1038776]: openjdk version "" 2020-11-04
Nov 13 09:35:43 tattve jenkins[1038776]: OpenJDK Runtime Environment (build
Nov 13 09:35:43 tattve jenkins[1038776]: OpenJDK 64-Bit Server VM (build, mixed mode, sharing)
Nov 13 09:35:43 tattve jenkins[1038744]: 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
# 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:

Added by: Eden Ebert

Answer: 3

30 hours ago

Jenkins required java version

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

Maintain multible Java version in Ubuntu

The this post on howto maintain multible Java versions.

Install Jenkins (as Debian package from

There is some very easy documentation on how to install the upstream jenkins Debian packages.

$ wget -q -O - | sudo apt-key add
$ sudo bash -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'
$ sudo apt update
$ sudo apt-get install jenkins

That should do the trick.

Remove Jenkins

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.

Added by: Shad Mayer

Answer: 4

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 Open browser http://localhost:9090 to start config of jenkins

Answer: 5

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

Added by: Leslie Bartell

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9