Can I install java 8 on Travis CI for a python project?

I have a python project that also requires Java 8 to run the tests and thus fails because Travis CI uses Java 7 by default. I know this can be updated if the project is a Java project but mine is python. I have a travis.yml file like below:

language: python
python:
- '2.7'
...

I have tried installing Java 8 using the following methods

language: python
python:
- '2.7'
jdk:
  - oraclejdk8
...

and

language: python
python:
- '2.7'
script:
- jdk_switcher use oraclejdk8
...

Any idea if this is possible? I'm thinking it might not be.


In the container-based infrastructure the following should do it:

language: python
 python:
   - "2.7"
addons:
  apt:
    packages:
      - oracle-java8-installer
...

As of 14 November 2016, with this commit, the following installs and activates Java 8:

addons:
  apt:
    packages:
      - oracle-java8-set-default