macOS change java to 11

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!

2 Likes

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

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:

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:

3 Likes

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

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!