# JAVA8\_HOME not found while running tests

**URL:** <https://discuss.elastic.co/t/java8-home-not-found-while-running-tests/212976>\
**Category:** Elasticsearch\
**Created:** [December 24, 2019, 5:35pm UTC](https://discuss.elastic.co/t/java8-home-not-found-while-running-tests/212976 "2019-12-24T17:35:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CroissantBlanc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/croissantblanc/32/59929_2.png) [@CroissantBlanc](https://discuss.elastic.co/u/CroissantBlanc)\
**Post date:** [December 24, 2019, 5:35pm UTC](https://discuss.elastic.co/t/java8-home-not-found-while-running-tests/212976/1 "2019-12-24T17:35:23Z")

</div>

Hi,

This is my first post, so I apologize if something is not as clear as it should be. I am sure the next ones will be better 🙂

I want to contribute to the project so I forked and cloned the github repo and I managed to assemble the project but when I execute the check task to run the tests the system prints that it is necessary JAVA8\_HOME although I have it added to my .bashrc

I tried first with the openjdk-8 and then uninstalling and installing the oracle jdk and I got the same result.

Thanks in advance for your help!

 ![ESGradle_Assemble](https://us1.discourse-cdn.com/elastic/original/3X/e/2/e232d641049e687902be9b3a42241cd5ab1496e8.png)

 ![ESPrintScreen](https://us1.discourse-cdn.com/elastic/original/3X/1/2/12726fbeb81122abc49bc32417cceb8aa8f1e76b.png)

---

<div class="post-metadata">

**Author:** ![Armin\_Braun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/armin_braun/32/20092_2.png) [@Armin\_Braun](https://discuss.elastic.co/u/Armin_Braun)\
**Post date:** [December 24, 2019, 6:16pm UTC](https://discuss.elastic.co/t/java8-home-not-found-while-running-tests/212976/2 "2019-12-24T18:16:36Z")

</div>

Hi @CroissantBlanc

the problem seems to be that root does not have the `JAVA8_HOME` environment set and you're running `./gradlew check` via `sudo`. You shouldn't need to run the tests as `sudo` and fix your environment such that you can run tests as your normal user.  
If that's not an option for some reason, you should add `JAVA8_HOME` to root's environment as well.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![CroissantBlanc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/croissantblanc/32/59929_2.png) [@CroissantBlanc](https://discuss.elastic.co/u/CroissantBlanc)\
**Post date:** [December 27, 2019, 10:30am UTC](https://discuss.elastic.co/t/java8-home-not-found-while-running-tests/212976/3 "2019-12-27T10:30:35Z")

</div>

Hi @Armin_Braun

Lots of thanks for your answer, with it I have been able to find the underlying problem.

I explain here just in case someone gets stuck in the same way:

I was running `./gradle check` via `sudo` because the system threw a `Permission denied` exception when I ran with my user.

Taking a closer look to the permission issue I found that the file owner was root. And that is because this file was generated by `./gradle assemble`. That led me to the next question, why running this command with `sudo`? I ran it with `sudo` because if not, there was a `Permission denied` exception when running a `docker` command.

So that was the original problem, `docker` command by default is only allowed to `su`.

The next steps were:

1. Add my user to `docker` user group:  
`sudo usermod -aG docker $USER`
2. Refresh the user group (via log out - log in or [reload user's group](https://superuser.com/questions/272061/reload-a-linux-users-group-assignments-without-logging-out) switching primary group)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 24, 2020, 10:30am UTC](https://discuss.elastic.co/t/java8-home-not-found-while-running-tests/212976/4 "2020-01-24T10:30:39Z")

</div>

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