Custom Java ignored on macOS

Description of the issue

We are using custom Script step to install JDK 1.8.0_112 during our build since we need a slightly older version of JDK than the one shipped with the Xcode 10.1 stack (JDK 1.8.0_202). It has been working fine for quite some time, but now the manually installed JDK is never used and the default stack JDK is used instead.


Xcode 10.1.x (macOS 10.13)


We are using a script like this to install custom JDK:

curl -O -L ''
hdiutil attach jdk-8u112-macosx-x64.dmg
sudo installer -pkg /Volumes/JDK\ 8\ Update\ 112/JDK\ 8\ Update\ 112.pkg -target /
diskutil umount /Volumes/JDK\ 8\ Update\ 112
rm jdk-8u112-macosx-x64.dmg
export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home'

Previously, when running java -version it correctly reported java version "1.8.0_112", but now it continues to report java version "1.8.0_202". We even tried to disable the default JDK using:

sudo mv /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Info.plist /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Info.plist.disabled

And then the default JDK is not listed when running /usr/libexec/java_home -V, but using java -version still reports JDK 1.8.0_202.

Build log

An example log of running the script:

curl -O -L https://[REDACTED].com/jdk-8u112-macosx-x64.dmg
sudo installer -pkg '/Volumes/JDK 8 Update 112/JDK 8 Update 112.pkg' -target /
installer: Package name is JDK 8 Update 112
installer: Installing at base path /
installer: The install was successful.
diskutil umount '/Volumes/JDK 8 Update 112'
Volume JDK 8 Update 112 on disk2s1 unmounted
rm jdk-8u112-macosx-x64.dmg
/usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.0_202, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
    1.8.0_112, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
sudo mv /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Info.plist /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Info.plist.disabled
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
/usr/libexec/java_home -V
Matching Java Virtual Machines (1):
    1.8.0_112, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

Has there been any change on Bitrise that would make this fail?

Hello there, In this regard, on that step no,
Could you try your build on the Hybrid stack?


Thanks for the tip! The Hybrid stack works so we’ll switch to using that for now. Still I think it would be great if the Script worked on the Xcode stack as well.

Great, I thought that it would work better because that stack already has tools for android builds preinstalled :upside_down_face:

I’m glad you are back on track any ways!:tada:

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