编辑:各种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当我试图用一些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问题是,javac和java都更新到了它们的最新版本。
javac -version
javac 1.7.0_51
javac: no source files
Usage: javac <options> <source files>
where possible options include: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
)我只安装了一个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"))强制java回家。SBT = 0.13.1
系统是Mac 10.9.2 (小牛)
发布于 2014-07-05 16:56:29
您不能使用javaHome设置来指定用于启动sbt的java版本,该版本只会指定哪些JDK将在其中查找,以及它在分叉时将使用哪些二进制文件。不幸的是,sbt的启动脚本不知道如何查看这个javaHome设置并更新自己。
您使用的是什么sbt脚本?您能添加一个which sbt输出并向我们展示这个脚本的内容吗?最有可能的情况是,该文件正在提取MacOSX原生JDK,而不是您已安装的文件。
https://stackoverflow.com/questions/22086433
复制相似问题