Set Java version in Autograder

Hi,
it seems Java 8 is the default version used in the autograder, but Java 11 and 12 are also installed on the image.

I’d like to have my tests use a version greater than 8, how do make my tests run under Java 11 or 12?

Thanks,
John.

I haven’t looked at this, but I know there is often confusion about the topic of “post Java 8”. We run into this in our labs. Oracle took over around then (from 8 to 9), and there are different distributions, including the OpenJDK. I know because of the license agreements, lab distribution scripts sometimes stick with “Java 8” instead of accepting or even paying for developer accounts with Oracle.

It could be that GitHub / Microsoft doesn’t want to commit to an OracleJDK… or it could be that it just says “Java 8”, but is really using an OpenJDK build under the hood?

I’m not really bothered about the vendor, any JDK > 8 will do for me.

Anyway, through (much) trial and (many) error, I found a solution.

I added some shell commands into a dummy test to interrogate the environment the tests run in, sudo update-alternatives --config java returned a list of the installed versions.

Once I knew the names of the installed versions, I could select one in the Setup step of a test with (e.g., for java 12) sudo update-java-alternatives -s adoptopenjdk-12-hotspot-amd64.

The test now runs under Java 12 (JDK is from Adopt OpenJDK).

1 Like

You can also specify the JDK version in classroom.yml by adding

   steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: '15'

(See GitHub - actions/setup-java: Set up your GitHub Actions workflow with a specific version of Java)

this is the solution I ended up using, works a treat.

Thanks.

© 2017 GitHub, Inc.
with by
GitHub Education