diff --git a/pom.xml b/pom.xml
index 42bd926a2fcb..22d9dba61f53 100644
--- a/pom.xml
+++ b/pom.xml
@@ -159,6 +159,8 @@
1.1.1.6
1.1.2
+ ${java.home}
+
${test_classpath}
+ ${test.java.home}
true
@@ -1224,6 +1227,7 @@
launched by the tests have access to the correct test-time classpath.
-->
${test_classpath}
+ ${test.java.home}
true
@@ -1716,6 +1720,16 @@
+
+ test-java-home
+
+ env.JAVA_HOME
+
+
+ ${env.JAVA_HOME}
+
+
+
scala-2.11
diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala
index d3faa551a4b1..5f51f4b58f97 100644
--- a/project/SparkBuild.scala
+++ b/project/SparkBuild.scala
@@ -119,7 +119,9 @@ object SparkBuild extends PomBuild {
lazy val publishLocalBoth = TaskKey[Unit]("publish-local", "publish local for m2 and ivy")
lazy val sharedSettings = graphSettings ++ genjavadocSettings ++ Seq (
- javaHome := Properties.envOrNone("JAVA_HOME").map(file),
+ javaHome := sys.env.get("JAVA_HOME")
+ .orElse(sys.props.get("java.home").map { p => new File(p).getParentFile().getAbsolutePath() })
+ .map(file),
incOptions := incOptions.value.withNameHashing(true),
retrieveManaged := true,
retrievePattern := "[type]s/[artifact](-[revision])(-[classifier]).[ext]",
@@ -426,8 +428,10 @@ object TestSettings {
fork := true,
// Setting SPARK_DIST_CLASSPATH is a simple way to make sure any child processes
// launched by the tests have access to the correct test-time classpath.
- envVars in Test += ("SPARK_DIST_CLASSPATH" ->
- (fullClasspath in Test).value.files.map(_.getAbsolutePath).mkString(":").stripSuffix(":")),
+ envVars in Test ++= Map(
+ "SPARK_DIST_CLASSPATH" ->
+ (fullClasspath in Test).value.files.map(_.getAbsolutePath).mkString(":").stripSuffix(":"),
+ "JAVA_HOME" -> sys.env.get("JAVA_HOME").getOrElse(sys.props("java.home"))),
javaOptions in Test += "-Dspark.test.home=" + sparkHome,
javaOptions in Test += "-Dspark.testing=1",
javaOptions in Test += "-Dspark.port.maxRetries=100",