5
編輯:各種SBT選項SBT在編譯混合項目時給出「類文件錯誤版本51.0,應該是49.0」?
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
我正在試圖編譯Scala的項目,一些Java源時,下面的錯誤,錯誤是如下
[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的版本
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爲v 0.13.1
系統的Mac OSX 10.9.2(小牛)
「類文件錯誤版本51.0,應該是49.0」這意味着您在使用JDK 5中的類庫時使用JDK 5中的'javac'。請確保'JAVA_HOME'指向您的JDK 7安裝目錄。 – Jesper
在終端中試過:「export JAVA_HOME ='/ usr/libexec/java_home -v 1.7'」來指定JAVA_HOME,但仍然得到同樣的錯誤。 – user2943976
你的構建配置文件是怎麼樣的 - 'build.sbt'或'project/*。scala'文件?你使用任何?你可以在SBT控制檯上運行'show scalacOptions'和'show javaOptions'和'about'並將輸出添加到問題中? –