Specifying -java-home at command line works in some cases, but not in all.
See original GitHub issueSBT is awesome, but I seem to have to change my path to point to my preferred JDK in some cases.
Desired behavior SBT uses -java-home if specified
Actual behavior Specifying -java-home works in some cases, but not in all.
Evidence
me@myComputer:~/Documents/someCo/applications/code/myApp/WEB-INF$ $SBT_HOME/bin/sbt -java-home /usr/lib/jvm/latest-oracle-jdk Loading /home/me/tools/sbt-0.13/bin/sbt-launch-lib.bash [info] Set current project to MyAwesomeAppTest (in build file:/home/me/Documents/someCo/applications/code/myApp/WEB-INF/) test
Testing…
That worked as expected. Then I made the following change to my build.sbt file (commented out 2 lines, added 2 new lines):
//unmanagedJars in Compile ++= // Attributed.blankSeq((file(“/home/me/Documents/someCo/applications/code/myApp/WEB-INF/src/test/lib/”) * “*.jar”).get)
libraryDependencies += “org.scalatest” % “scalatest_2.10” % “1.9.1”
libraryDependencies += “junit” % “junit” % “4.10”`
Now there is a problem:
$SBT_HOME/bin/sbt -java-home /usr/lib/jvm/latest-oracle-jdk Loading /home/me/tools/sbt-0.13/bin/sbt-launch-lib.bash [info] Set current project to MyAwesomeAppTest (in build file:/home/me/Documents/someCo/applications/code/myApp/WEB-INF/) test [info] Updating {file:/home/me/Documents/someCo/applications/code/myApp/WEB-INF/}web-inf… [info] Resolving org.fusesource.jansi#jansi;1.4 … [info] Done updating. [info] Compiling 6 Scala sources and 4 Java sources to /home/me/Documents/someCo/applications/code/myApp/WEB-INF/target/scala-2.10/test-classes… [trace] Stack trace suppressed: run last test:compile for the full output. error java.io.IOException: Cannot run program “javac”: error=2, No such file or directory [error] Total time: 19 s, completed Nov 7, 2013 10:08:53 AM
I was able to get it to work again by modifying my path as follows:
me@myComputer:~/Documents/someCo/applications/code/myApp/WEB-INF$ echo $PATH /usr/lib/jvm/java-7-openjdk-amd64/bin:/home/me/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games me@myComputer:~/Documents/someCo/applications/code/myApp/WEB-INF$ PATH=/usr/lib/jvm/latest-oracle-jdk/bin:/home/me/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin me@myComputer:~/Documents/someCo/applications/code/myApp/WEB-INF$ $SBT_HOME/bin/sbt Loading /home/me/tools/sbt-0.13/bin/sbt-launch-lib.bash [info] Set current project to MyAwesomeAppTest (in build file:/home/me/Documents/someCo/applications/code/myApp/WEB-INF/) test [info] Compiling 6 Scala sources and 4 Java sources to /home/me/Documents/someCo/applications/code/myApp/WEB-INF/target/scala-2.10/test-classes…
Even More Desired Behavior Use -java-home if specified, else JDK_HOME if specified, else JAVA_HOME if specified, else try the PATH.
Actual Behavior JDK_HOME and JAVA_HOME are ignored. specifying -java-home works in some cases, but not in all.
System Details Ubuntu 12.04 64-bit java version “1.7.0_45” Java™ SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot™ 64-Bit Server VM (build 24.45-b08, mixed mode)
Other java versions (before setting my path):
java -version java version “1.7.0_25” OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
echo $JAVA_HOME /usr/lib/jvm/latest-oracle-jdk/jre
$JAVA_HOME/bin/java -version java version “1.7.0_45” Java™ SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot™ 64-Bit Server VM (build 24.45-b08, mixed mode)
echo $JDK_HOME /usr/lib/jvm/latest-oracle-jdk
$JDK_HOME/bin/java -version java version “1.7.0_45” Java™ SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot™ 64-Bit Server VM (build 24.45-b08, mixed mode)
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (3 by maintainers)
I put a
.sbtopts
file in my base directory containingmust end with a newline.
Sorry to awaken this old thread but I am trying to build an sbt project with a JDK that is not my system-wide default one. (It is something I will also need to do as part of an automation script which builds projects with various JDK’s, so I cannot avoid needing this).
What may I expect not working with the
javaHome := sys.env.get("JAVA_HOME") map file
way? And just making sure, is https://github.com/paulp/sbt-extras paulp’s script, and does it take special fiddling to compile a project with a path to a given JDK?Thanks!