# macOS change java to 11

**URL:** https://discuss.bitrise.io/t/macos-change-java-to-11/13833
**Category:** Tooling Issues
**Tags:** step, stack-updates, ios, android
**Created:** [August 4, 2020, 9:43am UTC](https://discuss.bitrise.io/t/macos-change-java-to-11/13833 "2020-08-04T09:43:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![maciej.stramski.orm](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@maciej.stramski.orm](https://discuss.bitrise.io/u/maciej.stramski.orm)
#### Post date: [August 4, 2020, 9:43am UTC](https://discuss.bitrise.io/t/macos-change-java-to-11/13833/1 "2020-08-04T09:43:51Z")

</div>

I am trying to update java to version 11 with this script step:  
#!/usr/bin/env bash

```
set -ex

/usr/libexec/java_home -V

brew cask install java11

export JAVA_HOME=`/usr/libexec/java_home -v 11.0`
export PATH=$PATH:$JAVA_HOME/bin

source ~/.bash_profile

echo "Java version check:"

/usr/libexec/java_home -V

echo "Java version check:"

java -version

```

last command is always shows java 8. How can I resolve that? I tried Hybrid stack already and it does not work.

The reason to have java 11 is that we need it for SonarQube step. (after uploading to sonarcloud it shows a warning that java 8 will be deprecated in October 2020)

Thanks in advance for any help with this!

---

<div class="post-metadata">

### Author: ![thang.ngo](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@thang.ngo](https://discuss.bitrise.io/u/thang.ngo)
#### Post date: [August 9, 2020, 6:45pm UTC](https://discuss.bitrise.io/t/macos-change-java-to-11/13833/2 "2020-08-09T18:45:16Z")

</div>

I have the same issue, as SonarCloud move to Java 11 I need that version on Mac VM

---

<div class="post-metadata">

### Author: ![mattmapadmi](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/mattmapadmi/32/1970_2.png) [@mattmapadmi](https://discuss.bitrise.io/u/mattmapadmi)
#### Post date: [August 15, 2020, 11:07am UTC](https://discuss.bitrise.io/t/macos-change-java-to-11/13833/3 "2020-08-15T11:07:34Z")

</div>

The way I’ve done it is to use the pre-installed Brew version of Java 13, and JEnv to shim it:

```
jenv add /usr/local/opt/openjdk/
jenv global 13

```

For Android I’m following similar instructions that’s in the [Bitrise docs](https://devcenter.bitrise.io/tips-and-tricks/android-tips-and-tricks/#installing--using-java-version-x):

```
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt -y install openjdk-13-jdk

```

This works for iOS, but I have not tested with Android yet as I’m not the owner of any Android projects on my company’s Bitrise.

I’ve published the above as two steps on Github. Details on how to use them are in this blog post:

> **[Preparing Bitrise for SonarScanner’s Java 8 deprecation](https://chedabob.medium.com/preparing-bitrise-for-sonarscanners-java-8-deprecation-2d047ad6661e)**
>
> If you’re using SonarScanner as part of your build, you will have no doubt seen the warnings in the logs and on SonarQube/Cloud about the…

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/d/d901cf2aad020f2dd11918afc89ec2089bb87b35.png) [@system](https://discuss.bitrise.io/u/system)
#### Post date: [September 14, 2020, 11:07am UTC](https://discuss.bitrise.io/t/macos-change-java-to-11/13833/4 "2020-09-14T11:07:35Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

### Author: ![cathy.harmon](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/cathy.harmon/32/2674_2.png) [@cathy.harmon](https://discuss.bitrise.io/u/cathy.harmon)
#### Post date: [October 29, 2020, 5:55pm UTC](https://discuss.bitrise.io/t/macos-change-java-to-11/13833/5 "2020-10-29T17:55:35Z")

</div>

Just wanted to update here with good news! The stacks now have both openjdk 8 and openjdk 11 installed. By default, openjdk 8 will be active. To change to use openjdk 11, you just need a simple script step. Instructions and what needs to be in the script - - all documented in our devcenter!

> **[Virtual machines](https://devcenter.bitrise.io/infrastructure/virtual-machines/#managing-java-versions)**
>
> On bitrise.io, we run your builds on macOS and Linux virtual machines. You can select from multiple stacks, each with its own list of preinstalled tool versions.
