1

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 message "incorrect java version found" was repeatedly 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?

I tried both sudo apt install openjdk-8-jre-headless and sudo apt install openjdk-8-jdk but java is not there in /usr/bin and /usr/lib/jvm has java8jdk but it doesn't have java in bin folder. Please see the command and the console output below.

sudo apt install openjdk-8-jdk
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following packages were automatically installed and are no longer required:
daemon net-tools
Use 'sudo apt autoremove' to remove them.
Suggested packages: openjdk-8-demo openjdk-8-source visualvm
The following NEW packages will be installed
openjdk-8-jdk
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 0 B/1,435 kB of archives. After this operation, 1,538 kB of additional disk space will be used.
Selecting previously unselected package openjdk-8-jdk:amd64. (Reading database ... 168837 files and directories currently installed.)
Preparing to unpack .../openjdk-8-jdk_8u191-b12-2ubuntu0.18.04.1_amd64.deb ...
Unpacking openjdk-8-jdk:amd64 (8u191-b12-2ubuntu0.18.04.1) ...
Setting up openjdk-8-jdk:amd64 (8u191-b12-2ubuntu0.18.04.1) ..
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode

When I tried openjdk-jre-headless I got the below

sudo apt install openjdk-8-jre-headless
Reading package lists... Done
Building dependency tree Reading state information... Done
openjdk-8-jre-headless is already the newest version (8u191-b12-2ubuntu0.18.04.1).
The following packages were automatically installed and are no longer required:
daemon libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxt-dev net-tools openjdk-8-jdk-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev 
Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded

Still no use. I am not able to find java. which java returns nothing. java -version returns following.... Command 'java' not found, but can be installed with: sudo apt install default-jre sudo apt install openjdk-11-jre-headless sudo apt install openjdk-8-jre-headless

Could someone please help me on this issue? How to install java correctly? After removing/uninstalling Jenkins also I tried to install java but no use. Is jenkins that I installed previously blocking any java installaion?

cmoetzing
  • 742
  • 3
  • 16
user7501425
  • 43
  • 2
  • 7

1 Answers1

1

Have you tried to add Java to your Environment Variables?

  1. Check your installed Java Versions and select the desired version sudo update-alternatives --config java

  2. Export your Java Path as enviroment variable export PATH=$PATH:/usr/java/jrex.x.x_xxx/bin/

  3. Add this line to your .bashrc file in your home dircetory. This will update your evironment variable when opening bash

Maybe this answer could help you.

  • No use. the "sudo update-alternatives --config java" returns 'update-alternatives: error: no alternatives for java' – user7501425 Apr 30 '19 at 17:20
  • 1)i removed the openjdk-8-jre-headless and re-installed again..very strange..now its installed properly and "which java" is returning /usr/bin/java..i am confused why its working now. 2)Should i install openjdk-8-jdk also along with this openjdk-8-jre-headless to run jenkins properly? please help – user7501425 Apr 30 '19 at 17:27
  • The difference between headless and non headless is the headless version is for server use where you don't have a graphical interface. By the way I would recommend you to use the openjdk-8-jdk-headless package because the jdk version has developer tools to compile java sources packaged. – alex071299 Apr 30 '19 at 17:33