I’m getting compile errors when running the compile task as the sources reference new classes in java.nio.file package that only appeared in Java 7.
I have the following in build.sbt:
javaHome := Some(file("/opt/jdk/jdk1.7.0"))
fork := true
In sbt:
> show java-home
[info] Some(/opt/jdk/jdk1.7.0)
It compiles and runs fine in Eclipse. How can I set up sbt to use Java 7 for compilation?
The most reliable (perhaps only) way to do this at the moment it to start SBT with
javain the JDK7 folder.Modify your
sbtlauncher script; or use this one that allows you to specify Java Home (and so much more!) as command line options.Simply setting
javaHome := Some(file("/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home"))changes the Java version used to compile and fork processes, but does not change the version of the Java standard library on the classpath, nor the version used to run tests, which are always run the the same JVM as SBT.