JAVA_HOME is not exported for arm64 architecture

I see a strange behavior that I believe is a bug.

If I use the following config:

language: java
jdk: oraclejdk11

    - echo $JAVA_HOME 
    - false

then the outcome is:

$ java -Xmx32m -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
$ javac -J-Xmx32m -version
javac 11.0.2
0.00s$ echo $JAVA_HOME
0.00s$ false

But if I add arch: arm64 to the config:

language: java
jdk: oraclejdk11
arch: arm64

    - echo $JAVA_HOME 
    - false

then JAVA_HOME is empty:

$ java -Xmx32m -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)
$ javac -J-Xmx32m -version
javac 11.0.5
0.02s$ echo $JAVA_HOME
0.01s$ false

Thanks for the report. I took a quick look.

We are installing adoptopenjdk-*-hotspot package I believe the expectation was that these packages would set necessary environment variables, but probably that was wrong. We will look into it.


does not mention $JAVA_HOME for Linux installation.

We can guess the value based on files at hand, and it would go something like this:

f=$(which javac)
while [[ -L $f ]]; do f=$(readlink $f); done
export JAVA_HOME=${f%/bin/*}

The result is something like this:

Could you add the snippet above in your build and see if that meets your needs?


Thank you for the workaround! It helps!

Did that work for you?

But I think it would be better if it is consistent in both environments.

Not clear to me that would be possible, given that we use different mechanisms to install the Java packages.

Is that solicitation for a patch? :slight_smile: