Skip to content
Advertisement

Can’t Install Jenkins even though I have JAVA 8

Ubuntut 14.04 LTS

According to this I need JAVA 8 and so I downloaded both the JDK and JRE. Unfortunately when attempting to install jenkins again

sudo apt-get install jenkins

I still get the error message

Aborting
invoke-rc.d: initscript jenkins, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/jenkins_2.176.2_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Found an incorrect Java version
Java version found:
java version "1.7.0_201"
OpenJDK Runtime Environment (IcedTea 2.6.17) (7u211-2.6.17-0ubuntu0.1)
OpenJDK 64-Bit Server VM (build 24.201-b00, mixed mode)

Checking my $PATH and it shows the following

/usr/lib/jvm/jre1.8.0_221/bin:/usr/lib/jvm/jdk1.8.0_211/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

The java that should be used is 8. Even running

java -version

Gives me what I expect

java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

Why do I get the java version error if I have JAVA 8 installed? What more do I have to do to ensure that JAVA 8 is the default?

I was unsuccessful in trying

sudo apt-get install openjdk-8-jre

and got

Unable to locate package openjdk-8-jre

Side note, when attempting to run eclipse from the side bar I get an error about the JAVA version as well. Running eclipse from command line works fine though.

Does it have to with default-java symbolic link in my /usr/lib/jvm folder? It points to the Java 7 openjdk… Doing ls -la shows the links

default-java -> java-1.7.0-openjdk-amd64
java-1.7.0-openjdk-amd64 -> java-7-openjdk-amd64
java-7-openjdk-amd64

Advertisement

Answer

Looking into update-java-alternatives and update-alternatives, I came across this answer

I checked the current alternatives for java

sudo update-alternatives --config java

and got

There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
Nothing to configure.

Using one of the answers I found, I added the alternative for the java executable doing the following command

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.8.0_221/bin/java 1

Then I checked again to see that my alternate java was available in the list

sudo update-alternatives --config java

Which now gave me

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
* 1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
  2            /usr/lib/jvm/jre1.8.0_221/bin/java               1         manual mode

Press enter to keep the current choice[*], or type selection number: 

Then I entered 2 and tried to install and it worked. I can even run eclipse now from the side bar instead of having to run it from command line.

I appreciate the point in the right direction RealSkeptic!

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement