My scala application will only run with Java 7 as it depends on libraries that only appeared in that version of the JDK.
How do I enforce that in sbt, so that the correct error message is shown immediately to the user if she is using the wrong version of Java when starting sbt to run/compile the application?
NOTE: There is NO Java™ source code to compile here. I only have Scala source code. The Scala code requires an import java.nio.file.Path
that's available from Java 7.
Best Answer
Using
javacOptions ++= Seq("-source", "1.7", "-target", "1.7")
does not work if you have no Java sources.But you can set the target JVM for the Scala compiler in build.sbt or Build.scala:
As a result it prints on a JDK 6:
Note: Maybe it works only for the latest SBT/Scalac version.