Java/JDK on Travis CI

Travis CI should streamline its Java/JDK support on all environments.

  1. Pre-install “all” GA JDK versions from 5-11. Use an external tool to switch between those JDKs, like “sdkman!” or “jabba” or …

  2. Only JDK-ea versions should be installed “on-the-fly” from java.net (via install-jdk.sh)

Cheers,
Christian

2 Likes

I come here from this thread.

I’m trying to use openjdk6 in trusty environment exactly as the documentation tell me to do. By installing openjdk-6-jdk package using apt addon. For example:

addons:
  apt:
    packages:
      - openjdk-6-jdk
jdk: openjdk6

But the problem is that install-jdk.sh script is executed with an invalid parameter --feature "6". This script terminate the build execution with the following error message:

Expected feature release number in range of 9 to 13, but got: 6
The command "~/bin/install-jdk.sh --target "/home/travis/openjdk6" --workspace "/home/travis/.cache/install-jdk" --feature "6" --license "GPL" --cacerts" failed and exited with 3 during .

I was expecting Travis CI to not execute install-jdk.sh for openjdk6.

This is an example: https://travis-ci.com/saeg/jaguar2/builds/98821170

Notice that for openjdk7, oraclejdk8 and oraclejdk9 the script install-jdk.sh is not executed at all. But the jdk_switcher is executed instead. After Installing JDK phase, Installing APT Packages phase is executed installing OpenJDK 6.

Again, for openjdk6 I was expecting Installing APT Packages phase to run before Installing JDK phase and this later phase to only execute jdk_switcher use openjdk6.

Regards

Roberto

I would like to upgrade from Trusty to use Xenial or Bionic since Trusty is EOL. However, only Trusty supports JDK 7 and JDK 8.

We should be able to get OpenJDK8 working on Xenial or Bionic by adding the packages:

addons:
 apt:
  packages:
   - openjdk-8-jdk

Alas, when this is done, Travis does not understand that OpenJDK8 is available, and instead calls install-jdk.sh which fails because it isn’t designed to install JDKs older than 9. (See Why no more support for JDK 8.)

Can’t Travis be fixed to support OpenJDK8? (My users are demanding Java 7 and Java 8 support still. I’m open to stopping Java 7 since it is EOL, but Java 8 should still be supported.)

Thank you for your patience here.

I believe you should be able to use OpenJDK 8 on Xenial with the following in your .travis.yml file:

dist: xenial

language: java
jdk: openjdk8

See my test build here: https://travis-ci.org/cotsog/travis_ci_prod_regular/jobs/586205046#L190📖.

Could you try this out and let me know if it works on your side as well?

Xenial works for JDK 8, but I can’t get JDK 7 working unless I use Trusty.
Also, Bionic won’t allow JDK 8 – it appears to have an artificial limit a version between 9 and 14.

In the meantime, I compromised by dropping JDK 7 support for my project and moved to Xenial for JDK 8+ support.