# Install of openjDK 8 failing on Xenial builds

**URL:** <https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043>\
**Category:** Linux\
**Tags:** travis-build\
**Created:** [June 2, 2022, 5:09pm UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043 "2022-06-02T17:09:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alt-k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/alt-k/32/8011_2.png) [@alt-k](https://travis-ci.community/u/alt-k)\
**Post date:** [June 2, 2022, 5:09pm UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043/1 "2022-06-02T17:09:24Z")

</div>

Hi community !

Since today we are having issues during builds on xenial environment.  
Our TravisCI configuration has not changed since a while.  
We use the openJDK 8 but the installation does not work as expected:

```auto
Installing openjdk8
OK
E: Unable to locate package temurin-8-jdk
$ export JAVA_HOME=/usr/lib/jvm/temurin-8-jdk-amd64
$ export PATH="/usr/lib/jvm/temurin-8-jdk-amd64/bin:/home/travis/bin:/home/travis/.local/bin:/usr/local/lib/jvm/openjdk11/bin:/opt/pyenv/shims:/home/travis/.phpenv/shims:/home/travis/perl5/perlbrew/bin:/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.11.1.linux.amd64/bin:/usr/local/maven-3.6.3/bin:/usr/local/cmake-3.12.4/bin:/usr/local/clang-7.0.0/bin:/home/travis/.nvm/versions/node/v8.12.0/bin:/home/travis/.rvm/gems/ruby-2.5.3/bin:/home/travis/.rvm/gems/ruby-2.5.3@global/bin:/home/travis/.rvm/rubies/ruby-2.5.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/travis/.rvm/bin:/home/travis/.phpenv/bin:/opt/pyenv/bin:/home/travis/.yarn/bin"
update-java-alternatives: directory does not exist: /usr/lib/jvm/temurin-8-jdk*
...
$ mvn --settings .travis.settings.xml install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

```

Is there a known issue on Xenial with openjdk8?

Below the Travis CI configuration:

```auto
dist: xenial

language: java

cache:
  directories:
    - "${HOME}/.m2"

jdk:
  - openjdk8

```

---

<div class="post-metadata">

**Author:** ![MrCreosote](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/mrcreosote/32/5113_2.png) [@MrCreosote](https://travis-ci.community/u/MrCreosote)\
**Post date:** [June 2, 2022, 6:57pm UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043/2 "2022-06-02T18:57:16Z")

</div>

It appears as though java 11 is being set up instead of java 8. From a openjdk8 build 21 hours ago:

```auto
Installing openjdk8

*snip*

$ java -Xmx32m -version

openjdk version "1.8.0_292"

OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~16.04.1-b10)

OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)

$ javac -J-Xmx32m -version

javac 1.8.0_292

```

On a failing build run a few minutes ago:

```auto
Installing openjdk8

*snip*

$ java -Xmx32m -version

openjdk version "11.0.2" 2019-01-15

OpenJDK Runtime Environment 18.9 (build 11.0.2+9)

OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

$ javac -J-Xmx32m -version

javac 11.0.2

$ pipenv run ant $ANT_TEST

Error: JAVA_HOME is not defined correctly.

  We cannot execute /usr/lib/jvm/temurin-8-jdk-amd64/bin/java

The command "pipenv run ant $ANT_TEST" exited with 1.

```

---

<div class="post-metadata">

**Author:** ![aftenkap](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/aftenkap/32/8012_2.png) [@aftenkap](https://travis-ci.community/u/aftenkap)\
**Post date:** [June 2, 2022, 9:57pm UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043/3 "2022-06-02T21:57:03Z")

</div>

Running into the same issue.  
Key is really

```auto
E: Unable to locate package temurin-8-jdk

```

(i.e., apt-get install temurin-8-jdk fails)

However, ironically OpenJDK 8 is already installed on Xenial by default.

So, temporary workaround is to add the following to your .travis.yml:

```auto
env:
  global:
    - JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
    - PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH

```

Documentation on [The Xenial Build Environment - Travis CI](https://docs.travis-ci.com/user/reference/xenial/#jvm-clojure-groovy-java-scala-support) is also incorrect (which states that OpenJDK 8 is the default JDK – it defaults to OpenJDK 11), so trying to use the alleged default JDK will not work.

---

<div class="post-metadata">

**Author:** ![benwaffle](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/benwaffle/32/7756_2.png) [@benwaffle](https://travis-ci.community/u/benwaffle)\
**Post date:** [June 3, 2022, 1:45am UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043/4 "2022-06-03T01:45:00Z")

</div>

Seeing the same issue with openjdk13

---

<div class="post-metadata">

**Author:** ![CHaNGeTe](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/changete/32/8018_2.png) [@CHaNGeTe](https://travis-ci.community/u/CHaNGeTe)\
**Post date:** [June 3, 2022, 1:07pm UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043/5 "2022-06-03T13:07:39Z")

</div>

Seems Travis keys for git-lfs are wrong.  
Probably you are seeing something like:  
Failed to fetch [https://packagecloud.io/github/git-lfs/ubuntu/dists/xenial/InRelease](https://packagecloud.io/github/git-lfs/ubuntu/dists/xenial/InRelease) The following signatures couldn’t be verified because the public key is not available: NO\_PUBKEY

---

<div class="post-metadata">

**Author:** ![mustafaergul](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/mustafaergul/32/7814_2.png) [@mustafaergul](https://travis-ci.community/u/mustafaergul)\
**Post date:** [June 3, 2022, 1:18pm UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043/6 "2022-06-03T13:18:54Z")

</div>

Hey Folks,

We have made some changes in managing multiple JDK versions within our image. Your builds should be OK from now on. Please let us know if you still encounter problems with JDK.

Thanks  
Mustafa  
Travis CI Staff

---

<div class="post-metadata">

**Author:** ![bigethan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/bigethan/32/8021_2.png) [@bigethan](https://travis-ci.community/u/bigethan)\
**Post date:** [June 3, 2022, 7:39pm UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043/7 "2022-06-03T19:39:51Z")

</div>

I’m still seeing this issue with `jdk: oraclejdk13` leading to `ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-13-amazon-corretto` when verifying before installing (none of this bit of code has changed in years, and was working within the last two days)

---

<div class="post-metadata">

**Author:** ![adimiz1](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/adimiz1/32/8025_2.png) [@adimiz1](https://travis-ci.community/u/adimiz1)\
**Post date:** [June 6, 2022, 5:59am UTC](https://travis-ci.community/t/install-of-openjdk-8-failing-on-xenial-builds/13043/8 "2022-06-06T05:59:53Z")

</div>

Still getting this issue: `ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-10-amazon-corretto`, code was working before.
