我正在尝试从源代码构建Elasticsearch.我今天从GitHub回购克隆,我按照" 从源头构建 "中的说明进行操作.
运行./gradlew assemble
会产生以下错误:
... > Configure project :benchmarks ======================================= Elasticsearch Build Hamster says Hello! ======================================= Gradle Version : 4.7 OS Info : Linux 4.4.0-112-generic (amd64) JDK Version : Oracle Corporation 1.8.0_161 [Java HotSpot(TM) 64-Bit Server VM 25.161-b12] JAVA_HOME : /usr/lib/jvm/java-8-oracle Random Testing Seed : 5554B47DBBCF3CFB 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 '/elasticsearch-master/benchmarks/build.gradle' line: 31 * What went wrong: A problem occurred evaluating project ':benchmarks'. > Failed to apply plugin [id 'elasticsearch.build'] > the environment variable JAVA_HOME must be set to a JDK installation directory for Java 1.10 but is [/usr/lib/jvm/java-8-oracle] corresponding to [1.8] ...
运行sudo ./gradlew assemble
会产生不同的错误:
FAILURE: Build failed with an exception. * Where: Build file '/elasticsearch-master/benchmarks/build.gradle' line: 31 * What went wrong: A problem occurred evaluating project ':benchmarks'. > Failed to apply plugin [id 'elasticsearch.build'] > JAVA_HOME must be set to build Elasticsearch
但据我所知,我JAVA_HOME
的确定:
$ echo $JAVA_HOME /usr/lib/jvm/java-8-oracle $ sudo echo $JAVA_HOME /usr/lib/jvm/java-8-oracle $ ls /usr/lib/jvm/java-8-oracle bin COPYRIGHT db include javafx-src.zip jre lib LICENSE man README.html release src.zip THIRDPARTYLICENSEREADME-JAVAFX.txt THIRDPARTYLICENSEREADME.txt
其他可能有用的信息:
$ java -version java version "1.8.0_161" Java(TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode) $ gradle -v ------------------------------------------------------------ Gradle 4.7 ------------------------------------------------------------ Build time: 2018-04-18 09:09:12 UTC Revision: b9a962bf70638332300e7f810689cb2febbd4a6c Groovy: 2.4.12 Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017 JVM: 1.8.0_161 (Oracle Corporation 25.161-b12) OS: Linux 4.4.0-112-generic amd64
我正在运行Ubuntu 16.04.
任何人都知道如何修复此错误(或者,如何从源代码构建最新版本的Elasticsearch),而无需升级到Java 10?
我终于明白了.回想起来,这听起来像是一个愚蠢的问题,但是如果有人发现它有帮助的话,我会把它留给这个答案.
当Elasticsearch 说它只需要Java 8时,它实际上意味着Java 8足以运行 Elasticsearch.构建 Elasticsearch是完全不同的,似乎需要Java 10(我假设正在使用Java 10功能).因此,如果要从源构建Elasticsearch,则必须升级到Java 10.