scala – SBT在编译混合项目时给出“类文件有错误版本51.0,应该
发布时间:2020-12-16 18:28:17 所属栏目:安全 来源:网络整理
导读:编辑:各种SBT选项 show scalacOptionsList(-deprecation,-unchecked,-encoding,UTF-8,-Yinline-warnings,-feature)show javaOptionsList()about[info] This is sbt 0.13.1[info] The current project is {file:/Users/ThomasNorth/Documents/CODE/SERVER/Mo
编辑:各种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 Osx 10.9.2(小牛队) 解决方法
您不能使用javaHome设置来指定用于启动sbt的java版本,该版本仅指定将查找哪个JDK sbt,以及它在分叉时将使用哪些二进制文件.不幸的是,sbt的启动脚本不知道如何查看这个javaHome设置并自行更新.
你用的是什么脚本?你能添加一个sbt输出,并向我们展示这个脚本的内容吗?很可能这个文件是拉动MacOSX本机JDK而不是你安装的那个. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |