Cannot Build Using Gradle; JAVA_HOME Not found

(Somebody Someone) #1

I am trying to build on the custom-realm-example as published on github. However, no matter what I do I am unable to build the project. Here's some details on what's going on:

➜  shield-custom-realm-example git:(master) echo $JAVA_HOME
➜  shield-custom-realm-example git:(master) java -version
'java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
➜  shield-custom-realm-example git:(master) ./gradlew

> Configure project :
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file '~/dev/temp/shield-custom-realm-example/build.gradle' line: 39

* What went wrong:
A problem occurred evaluating root project 'x-pack-custom-realm-extension-example'.
> Failed to apply plugin [id '']
   > JAVA_HOME must be set to build Elasticsearch

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.

➜  shield-custom-realm-example git:(master)

(David Pilato) #2

JAVA_HOME must be set to build Elasticsearch

(Somebody Someone) #3

That's why I had this shown in the above logs.

shield-custom-realm-example git:(master) echo $JAVA_HOME

(David Pilato) #4

Can you try with Java8 or Java9?

(Ryan Ernst) #5

Do you have the gradle daemon enabled? Try running ./gradlew --stop and then running your build again. Also, is your JAVA_HOME variable exported?

(Somebody Someone) #6

@dadoonet I could not find a site that would allow me download java9 JDK, seems like oracle has removed it? I cant use JDK8 to build elasticsearch 6 plugins

@rjernst Please look at the first two lines in the logs I posted above. I have echoed the $JAVA_HOME variable, is there more than that to it?

(David Pilato) #7

I'm using sdkman to switch from one jvm to another. Give it a try may be?

(Tim Vernum) #8

@rjernst asked if the JAVA_HOME is exported. That is different to simply setting the variable.

If you want the variable to be available to a child process (which you do) then you need to

export JAVA_HOME

(andy_zhou) #9

before build export JAVA_HOME with you correct java

(system) #10

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