Machine Executor with JDK 11

I have an application that uses JDK 11 and this application also uses a docker library (Testcontainer) for testing and I therefore need to use the Machine type executor.
The default ubuntu image for machine type runs on JDK8.

Is there already a new Ubuntu image with JDK 11 installed or how can I achieve this?

1 Like

Hi @chemika,

Welcome to the CircleCI community!

I would suggest using the new ubuntu-2004:202008-01 machine executor image, already available for early preview. It comes with OpenJDK 11 as the default version.

However, I strongly advise you to read this post before deciding to use that new image.

Alternatively, you could keep using the ubuntu-1604:202007-01 machine image and upgrade OpenJDK to version 11, as follows:

version: 2.1

jobs:
  build:
    machine:
      image: ubuntu-1604:202007-01
    steps:    
      - run:
          name: Install OpenJDK 11
          command: |
            sudo apt-get update && sudo apt-get install openjdk-11-jdk
            sudo update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
            sudo update-alternatives --set javac /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
            java -version
                   
workflows:
  build_and_test:
    jobs:
      - build

@yannCI Thanks …This was really helpful…

1 Like

is there an image for jdk-17?

@wind57
now there is: Ubuntu Linux VM (machine) Images - 2022 April (Q2) Update

1 Like

awesome! thank you for tagging me in here

Hey all.
With the new LTS release JDK 21, any plans CircleCI team has to provide an image with JDK21 available?