# Installing Java 14 fails with "travis\_setup\_java: command not found"

**URL:** <https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626>\
**Category:** Java\
**Created:** [May 15, 2020, 10:24pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626 "2020-05-15T22:24:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/softwaredoug/32/4596_2.png) [@softwaredoug](https://travis-ci.community/u/softwaredoug)\
**Post date:** [May 15, 2020, 10:24pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/1 "2020-05-15T22:24:12Z")

</div>

Hi, I help maintain the [Elasticsearch Learning to Rank Plugin](http://github.com/o19s/elasticsearch-learning-to-rank). As part of this Pull Request, we are upgrading to [Elasticsearch 7.7](https://github.com/o19s/elasticsearch-learning-to-rank/pull/306). Part of this Elasticsearch now requires Java 14, so we updated our config to oraclejdk14. It seemed to work up until tonight when we were receiving the error when the install Java runs

```auto
travis_fold:start:install_jdk
e[0Ke[33;1mInstalling oraclejdk14e[0m
travis_setup_java: command not found
travis_fold:end:install_jdk

```

Subsequent `java -version` returns:

```auto
$ 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)

```

Failure to install Java 14 gives the error when building our code that Java is not up to date:

```auto
FAILURE: Build failed with an exception.

* Where:
Build file '/home/travis/build/o19s/elasticsearch-learning-to-rank/build.gradle' line: 18

* What went wrong:
A problem occurred evaluating root project 'ltr'.
> Failed to apply plugin [class 'org.elasticsearch.gradle.info.GlobalBuildInfoPlugin']
   > The compiler java.home must be set to a JDK installation directory for Java 14 but is [/usr/local/lib/jvm/openjdk11] corresponding to [11]

```

---

<div class="post-metadata">

**Author:** ![pmeister](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/pmeister/32/5874_2.png) [@pmeister](https://travis-ci.community/u/pmeister)\
**Post date:** [May 15, 2020, 10:39pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/2 "2020-05-15T22:39:29Z")

</div>

We’re seeing something similar, though we require Java 8.

---

<div class="post-metadata">

**Author:** ![Ethelom](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ethelom/32/4602_2.png) [@Ethelom](https://travis-ci.community/u/Ethelom)\
**Post date:** [May 15, 2020, 10:46pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/3 "2020-05-15T22:46:50Z")

</div>

Same thing happens with other jdks such as:

- opendjk8
- oraclejdk10

---

<div class="post-metadata">

**Author:** ![ProTip](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/protip/32/2685_2.png) [@ProTip](https://travis-ci.community/u/ProTip)\
**Post date:** [May 16, 2020, 12:09am UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/4 "2020-05-16T00:09:17Z")

</div>

Our release build is failing Java Compile now as well. This error is new:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/travis_ci/original/2X/d/d70afaa4d17d539a4b766a4574b30434d9d70dd1.png)

---

<div class="post-metadata">

**Author:** ![LorenzoBettini](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/lorenzobettini/32/4237_2.png) [@LorenzoBettini](https://travis-ci.community/u/LorenzoBettini)\
**Post date:** [May 16, 2020, 3:04pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/5 "2020-05-16T15:04:34Z")

</div>

Same here with openjdk8

---

<div class="post-metadata">

**Author:** ![GhostNA](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ghostna/32/4610_2.png) [@GhostNA](https://travis-ci.community/u/GhostNA)\
**Post date:** [May 16, 2020, 8:40pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/6 "2020-05-16T20:40:39Z")

</div>

Same issue, openjdk8

---

<div class="post-metadata">

**Author:** ![denzhel](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@denzhel](https://travis-ci.community/u/denzhel)\
**Post date:** [May 17, 2020, 10:31am UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/7 "2020-05-17T10:31:15Z")

</div>

Same for us, openjdk8

---

<div class="post-metadata">

**Author:** ![anatolyD](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@anatolyD](https://travis-ci.community/u/anatolyD)\
**Post date:** [May 17, 2020, 7:17pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/8 "2020-05-17T19:17:00Z")

</div>

getting the same :

```auto
Installing openjdk11
travis_setup_java: command not found

```

configs in travis.yaml:

```auto
      language: java
      jdk:
        - openjdk11
      script:
        - cd src/jvm/

```

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [May 17, 2020, 10:04pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/9 "2020-05-17T22:04:11Z")

</div>

When reporting problems, please consider including:

1. What you are trying to achieve
2. What you have tried (probably a link to the configuration)
3. What happened instead (often, pointing to a build log URL, in the form of [https://travis-ci.com/OWNER/REPO/build/NNNNNNN](https://travis-ci.com/OWNER/REPO/build/NNNNNNN) would be helpful).

---

<div class="post-metadata">

**Author:** ![GhostNA](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ghostna/32/4610_2.png) [@GhostNA](https://travis-ci.community/u/GhostNA)\
**Post date:** [May 17, 2020, 10:17pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/10 "2020-05-17T22:17:03Z")

</div>

> [@BanzaiMan](#):
>
> What you are trying to achieve

1. Install Openjdk8
2. 

```auto
language: java
jdk:
  - openjdk8
sudo: required

services:
- docker

cache:
  directories:
  - "$HOME/.gradle/caches/"
  - "$HOME/.gradle/wrapper/"

install:
- sudo pip install --quiet ansible==2.5.5

before_install:
 - chmod +x gradlew

script:
- "./gradlew check"
- "./gradlew codeCoverageReport"

after_success:
- "bash <(curl -s https://codecov.io/bash)"

deploy:
- provider: script
  script: bash travis/deploy/deploy.sh
  skip_cleanup: true
  on:
    all_branches: true
    condition: $TRAVIS_BRANCH =~ ^(staging|master|dev)$

```

1. 

```auto
resolvconf
install_jdk

Installing openjdk8

travis_setup_java: command not found

```

```auto
 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

```

---

<div class="post-metadata">

**Author:** ![phil-hildebrand](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/phil-hildebrand/32/3015_2.png) [@phil-hildebrand](https://travis-ci.community/u/phil-hildebrand)\
**Post date:** [May 17, 2020, 10:31pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/11 "2020-05-17T22:31:38Z")

</div>

We see the same issue with openjdk8.

Config:

[https://travis-ci.com/github/seomoz/feedstore/jobs/335454785/config](https://travis-ci.com/github/seomoz/feedstore/jobs/335454785/config)

Build Error:

[https://travis-ci.com/github/seomoz/feedstore/jobs/335454780#L161](https://travis-ci.com/github/seomoz/feedstore/jobs/335454780#L161)

Java ends up defaulting to openjdk11:

[https://travis-ci.com/github/seomoz/feedstore/jobs/335454780#L198](https://travis-ci.com/github/seomoz/feedstore/jobs/335454780#L198)

It started for us this past Friday, and we can repro the issue by retrying a previously passing build:

[https://travis-ci.com/github/seomoz/feedstore/jobs/334573722#L161](https://travis-ci.com/github/seomoz/feedstore/jobs/334573722#L161)

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/softwaredoug/32/4596_2.png) [@softwaredoug](https://travis-ci.community/u/softwaredoug)\
**Post date:** [May 18, 2020, 12:12am UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/12 "2020-05-18T00:12:04Z")

</div>

Thanks @BanzaiMan

Expected to happen: OpenJDK / Oracle Java 14 installed

Config

```auto
language: java
install: true
dist: bionic

jdk:
  - oraclejdk14
  - openjdk14

script:
  - ./gradlew clean check

```

What happened instead

- Test was run with Java 11 (system Java?)
- Apparent failure with Travis installing Java:

```auto
travis_fold:start:install_jdk
e[0Ke[33;1mInstalling oraclejdk14e[0m
travis_setup_java: command not found
travis_fold:end:install_jdk

```

Build Can Be Found here:

[https://travis-ci.com/github/o19s/elasticsearch-learning-to-rank/builds/166443238](https://travis-ci.com/github/o19s/elasticsearch-learning-to-rank/builds/166443238)

---

<div class="post-metadata">

**Author:** ![aerovulpe](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@aerovulpe](https://travis-ci.community/u/aerovulpe)\
**Post date:** [May 18, 2020, 12:39am UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/13 "2020-05-18T00:39:20Z")

</div>

I’m also seeing this issue, installing openjdk8 with `jdk: openjdk8`

---

<div class="post-metadata">

**Author:** ![Cadigal-displayr](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cadigal-displayr/32/4786_2.png) [@Cadigal-displayr](https://travis-ci.community/u/Cadigal-displayr)\
**Post date:** [May 18, 2020, 1:46am UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/14 "2020-05-18T01:46:26Z")

</div>

The issue seems to be that Travis does not have [this script](https://github.com/travis-ci/travis-build/blob/9e9b35ee8912fc0a1c8a978ba4b5702556570086/lib/travis/build/bash/travis_install_jdk.bash) that sets up the Java installation installed on their VMs anymore.  
A quick and dirty fix to get our CI working again is:

First, add this at the top of `before-install`

```auto
before_install:
  ##########
  # TEMPORARY hack to get around Travis not installing Java
  # Remove this and the ".travis_install_jdk.sh" file once Travis installs java properly again!
  # Copied from the output of the "install_jdk" task in our last successful build
  - export JAVA_HOME=~/openjdk14
  - export PATH="$JAVA_HOME/bin:$PATH"
  - ./.travis_install_jdk.sh --target "/home/travis/openjdk14" --workspace "/home/travis/.cache/install-jdk" --feature "14" --license "GPL" --cacerts
  ##########

```

Then download [this script](https://github.com/sormuras/bach/blob/8d66f6531ec99a4f2c5cbdad61d082b8ee734e1f/install-jdk.sh) and put it in the root of your repository as “`.travis_install_jdk.sh`”

---

<div class="post-metadata">

**Author:** ![mahajanishan2008](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@mahajanishan2008](https://travis-ci.community/u/mahajanishan2008)\
**Post date:** [May 18, 2020, 5:39am UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/15 "2020-05-18T05:39:40Z")

</div>

This script provides support for openJdk9 onwards. Can it be modified for openjdk8 as well? Getting below error. Looks like cacerts issue.

download error: Caught javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty (java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty) while downloading [https://repo1.maven.org/maven2/com/github/sbt/sbt-findbugs\_2.12\_1.0/2.0.0/sbt-findbugs-2.0.0.pom](https://repo1.maven.org/maven2/com/github/sbt/sbt-findbugs_2.12_1.0/2.0.0/sbt-findbugs-2.0.0.pom)

---

<div class="post-metadata">

**Author:** ![furuyamah](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/furuyamah/32/4614_2.png) [@furuyamah](https://travis-ci.community/u/furuyamah)\
**Post date:** [May 18, 2020, 7:06am UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/16 "2020-05-18T07:06:56Z")

</div>

My build problems with openjdk8 was resolved adding the env.

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

```

---

<div class="post-metadata">

**Author:** ![ashutoshgngwr](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@ashutoshgngwr](https://travis-ci.community/u/ashutoshgngwr)\
**Post date:** [May 18, 2020, 7:19am UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/17 "2020-05-18T07:19:04Z")

</div>

I decided to part ways from Travis CI’s helper scripts and stuff. Last time it didn’t work when setting up Android emulators. This time it failed with Java. IMO, a stable approach for anyone using OpenJDK is to install it and set the env PATH manually. The only catch is that I used the ‘minimal’ or ‘shell’ image as the base and it also had OpenJDK 11 installed by default.

Here’s my fix - [https://github.com/ashutoshgngwr/noice/commit/6d31fda81b51a6b5552f59a39dce1ec342fde04c](https://github.com/ashutoshgngwr/noice/commit/6d31fda81b51a6b5552f59a39dce1ec342fde04c)

I am sure similar fix can be invented for Oracle version also.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [May 18, 2020, 12:49pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/18 "2020-05-18T12:49:26Z")

</div>

There might have been a bad deployment. Could you restart the affected builds to confirm things are working as expected?

Thanks.

---

<div class="post-metadata">

**Author:** ![ashutoshgngwr](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@ashutoshgngwr](https://travis-ci.community/u/ashutoshgngwr)\
**Post date:** [May 18, 2020, 1:03pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/19 "2020-05-18T13:03:59Z")

</div>

@BanzaiMan The builds have been breaking for a few days now. I did restart them once or twice and it didn’t work at the time.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [May 18, 2020, 1:05pm UTC](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626/20 "2020-05-18T13:05:39Z")

</div>

I’m asking if it works now.

[Next page](https://travis-ci.community/t/installing-java-14-fails-with-travis-setup-java-command-not-found/8626.md?page=2)
