Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis Ci jdk_switcher to custom java installation

Tags:

java

travis-ci

I am developing a java application that needs a very recent version of java. Unfortunately travis-ci currently only supports jdk version 1.8.0_31.

Because of that I download the newes binary release from oracle and extract it to the $HOME directory:

before-script:
    - "wget --no-cookies --header \"Cookie: oraclelicense=accept-securebackup-cookie\" http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz -O /tmp/OracleJDK.tar.gz"
    - tar -xzvf /tmp/OracleJDK.tar.gz -C $HOME
    - export PATH=$PATH:$HOME/jdk1.8.0_60/bin
    - jdk_switcher use <???>

How do I tell travis to use the freshly downloaded jdk?

BTW: I'm not updating the jdk via apt-get because sudo commands are not supported yet with their new docker infrastructure.

like image 586
Tiim Avatar asked Jan 08 '23 15:01

Tiim


2 Answers

I solved this by using the travis apt addon like this:

jdk:
  - oraclejdk8

addons:
  apt:
    packages:
      - oracle-java8-installer

This automatically installs the newest java8 version without using sudo

like image 77
Tiim Avatar answered Jan 10 '23 03:01

Tiim


You might also want to use the oracle-java8-set-default package:

jdk:
  - oraclejdk8
addons:
  apt:
    packages:
      - oracle-java8-installer
      - oracle-java8-set-default

That did the trick for me.

like image 37
tmpfs Avatar answered Jan 10 '23 05:01

tmpfs