# JAVA\_HOME is not exported for arm64 architecture

**URL:** <https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993>\
**Category:** Multi CPU Architecture\
**Tags:** java, bug\
**Created:** [January 24, 2020, 9:54am UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993 "2020-01-24T09:54:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin-g](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/martin-g/32/3705_2.png) [@martin-g](https://travis-ci.community/u/martin-g)\
**Post date:** [January 24, 2020, 9:54am UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/1 "2020-01-24T09:54:41Z")

</div>

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

If I use the following config:

```auto
language: java
jdk: oraclejdk11

install:
    - echo $JAVA_HOME 
    - false

```

then the outcome is:

```auto
$ 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
install.1
0.00s$ echo $JAVA_HOME
/usr/local/lib/jvm/openjdk11
0.00s$ false

```

But if I add `arch: arm64` to the config:

```auto
language: java
jdk: oraclejdk11
arch: arm64

install:
    - echo $JAVA_HOME 
    - false

```

then `JAVA_HOME` is empty:

```auto
$ 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
install.1
0.02s$ echo $JAVA_HOME
0.01s$ false

```

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [January 24, 2020, 1:13pm UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/2 "2020-01-24T13:13:33Z")

</div>

Thanks for the report. I took a quick look.

We are installing `adoptopenjdk-*-hotspot` package [https://github.com/travis-ci/travis-build/blob/0d3f1f908897605ec66c0d04b2e150741c4381dc/lib/travis/build/bash/travis\_install\_jdk.bash#L45-L57](https://github.com/travis-ci/travis-build/blob/0d3f1f908897605ec66c0d04b2e150741c4381dc/lib/travis/build/bash/travis_install_jdk.bash#L45-L57) I believe the expectation was that these packages would set necessary environment variables, but probably that was wrong. We will look into it.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [January 24, 2020, 3:09pm UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/3 "2020-01-24T15:09:29Z")

</div>

Curiously,

> **[Installation | AdoptOpenJDK](https://adoptopenjdk.net/installation.html?variant=openjdk11&jvmVariant=hotspot#linux-pkg)**
>
> AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully open source set of build scripts and infrastructure. Supported platforms include Linux, macOS, Windows, ARM, Solaris, and AIX.

  
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:

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

```

The result is something like this: [https://travis-ci.org/BanzaiMan/travis\_production\_test/builds/641393626#L890](https://travis-ci.org/BanzaiMan/travis_production_test/builds/641393626#L890)

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

Thanks.

---

<div class="post-metadata">

**Author:** ![martin-g](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/martin-g/32/3705_2.png) [@martin-g](https://travis-ci.community/u/martin-g)\
**Post date:** [January 27, 2020, 12:18pm UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/4 "2020-01-27T12:18:31Z")

</div>

Thank you for the workaround! It helps!

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [January 27, 2020, 4:20pm UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/5 "2020-01-27T16:20:38Z")

</div>

Did that work for you?

---

<div class="post-metadata">

**Author:** ![martin-g](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/martin-g/32/3705_2.png) [@martin-g](https://travis-ci.community/u/martin-g)\
**Post date:** [January 27, 2020, 6:11pm UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/6 "2020-01-27T18:11:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [January 27, 2020, 6:48pm UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/7 "2020-01-27T18:48:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [January 28, 2020, 9:31am UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/8 "2020-01-28T09:31:28Z")

</div>

Is that solicitation for a patch? 🙂

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [January 28, 2020, 9:09pm UTC](https://travis-ci.community/t/java-home-is-not-exported-for-arm64-architecture/6993/10 "2020-01-28T21:09:31Z")

</div>

Anyway,

> <https://github.com/travis-ci/travis-build/pull/1846>
