编辑:各种SBT选项
show scalacOptions
List(-deprecation, -unchecked, -encoding, UTF-8, -Yinline-warnings, -feature)
show javaOptions
List()
about
[info] This is sbt 0.13.1
[info] The current project is {file:/Users/ThomasNorth/Documents/CODE/SERVER/MonetiseAlpha/monetise-webserver/}monetise-webserver 1.0.0-SNAPSHOT
[info] The current project is built against Scala 2.10.3
[info]
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.3
Run Code Online (Sandbox Code Playgroud)
我尝试使用一些Java源代码编译scala项目时收到以下错误,错误如下
[error] /Users/ThomasNorth/Documents/CODE/SERVER/MonetiseAlpha/monetise-webserver/src/main/java/com/boxbe/pub/email/EmailAddress.java:31: cannot access java.util.regex.Pattern
[error] bad class file: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar(java/util/regex/Pattern.class)
[error] class file has wrong version 51.0, should be 49.0
[error] Please remove or make sure it appears in the correct subdirectory of the classpath.
[error] import java.util.regex.Pattern;
[error] ^
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code
[error] Total time: 13 s, completed 28/02/2014 3:36:38 PM
Run Code Online (Sandbox Code Playgroud)
问题是,javac和java都更新到了他们的最新版本
javac -version
javac 1.7.0_51
javac: no source files
Usage: javac <options> <source files>
where possible options include:
Run Code Online (Sandbox Code Playgroud)
java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
build.sbt
organization := "com.monetise"
name := "webserver"
version := "1.0.0-SNAPSHOT"
scalaVersion := "2.10.3"
resolvers ++= Seq(
Resolver.sonatypeRepo("release"),
Resolver.sonatypeRepo("snapshots"),
"Untyped" at "http://ivy.untyped.com/com.untyped/"
)
scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
"-encoding", "UTF-8",
"-Yinline-warnings",
"-feature"
// "-Xcheckinit" // for debugging only, see https://github.com/paulp/scala-faq/wiki/Initialization-Order
// "-optimise" // this option will slow your build
)
Run Code Online (Sandbox Code Playgroud)
我只安装了一个sdk,它位于 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
任何人都有任何想法为什么会这样?
我甚至试图把它放在我的globals.sbt中
javaHome := Some(file("/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home"))
Run Code Online (Sandbox Code Playgroud)
强制java回家.SBT是0.13.1
系统是Mac Osx 10.9.2(小牛队)
您不能使用该设置来指定用于启动javaHome
sbt的 java 版本,这只会指定 JDK sbt 将查找哪个版本,以及在分叉时将使用哪些二进制文件。不幸的是,sbt 的启动脚本不知道如何查看此设置并自行更新。javaHome
sbt
你使用什么脚本?您可以添加一个which sbt
输出,并向我们展示该脚本的内容吗?该文件很可能正在拉取 MacOSX 本机 JDK,而不是您已安装的 JDK。