How can I check and change java runtime version in Bitbucket pipeline
Asked by Encarna G G Torres:

We upgrading to Java 17 , pipeline deployment fails with 'file has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0'

How can I check and change java runtime version in Bitbucket pipeline?


Answers:
author: Theodora Boudale
body: Hi Encarna and welcome to the community!

If the Pipelines builds run on Atlassian infrastructure, they use Docker containers. For every step of your build, a Docker container starts (the build container) using the image you have specified in your bitbucket-pipelines.yml file. The definition will look like this:

```
image: atlassian/default-image:4
```

and it may be defined either at the top of the file, to apply to all steps, or at a step level.

If you don't install Java during the build, then the version of Java is the one preinstalled already on the Docker image you use in your yml file.

You can figure it out either by adding the command**java --version** in your yml file and running a build, or you can also figure it out locally so that you don't consume build minutes.

If you have Docker installed on your computer, you can run the command

```
docker run -it atlassian/default-image:4 --entrypoint=/bin/bash
```

where **atlassian/default-image:4** replace with the image you use in your bitbucket-pipelines.yml file for the step that fails. The entrypoint may also need to be **/bin/sh** if the image uses sh instead of bash (you can first try **/bin/bash** and if it doesn't work, you can try **/bin/sh**).

This command will start on your computer a bash (or sh) prompt when the container starts and you can execute commands on the container, like **java --version**.

<br />

If you need a different version of Java, you can check first if the Docker image you use in your yml file has any newer tags and if the images with the newer tags have a newer version of Java (you can check locally first, the way I described above). Otherwise, you can try a different Docker image or build a custom Docker image with the version of Java and other tools you need, and use that in your yml file.

We support public and private Docker images including those hosted on Docker Hub, AWS, GCP, Azure, and self-hosted registries accessible on the internet. More info on Docker images as build environments in Pipelines:

* <https://support.atlassian.com/bitbucket-cloud/docs/use-docker-images-as-build-environments/>

Please feel free to let me know if you have any questions!

Kind regards,  
Theodora

comments: author: Encarna G G Torres
body: Hi Theodora,

Thanks for your response .

I already checked the java version of my docker image, and it is java 17 as expected. I suspect the issue might come on the Google app engine side

Kind regards,

Encarna


author: Theodora Boudale
body: Hi Encarna,

You are very welcome.

This might be the case if the environment in Google app engine is using an older version of Java. You can check if it is possible to change to a newer version of Java and then try another deployment.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud