如何在项目中更新 sbt? [英] How can I update sbt in project?
问题描述
我正在学习 Coursera 上关于 Scala 的课程,他们有作业要我做.我下载了项目,里面有 build.sbt
.我在终端、Eclipse 和 Idea 中尝试使用 sbt
命令,但没有任何效果.终端中的消息说:
I'm going through course on Coursera about scala, and they have assignments for me to do. I downloaded project and there is build.sbt
in it. I tried with sbt
command in terminal, Eclipse and Idea, nothing works. Message in terminal says:
[info] Compiling 8 Scala sources to /Users/(Path to project)/project/target/scala-2.9.2/sbt-0.12/classes...
[error] error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken
[error] (bad constant pool tag 18 at byte 10)
[error] error while loading Comparator, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar(java/util/Comparator.class)' is broken
[error] (bad constant pool tag 18 at byte 20)
[error] error while loading AnnotatedElement, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is broken
[error] (bad constant pool tag 18 at byte 76)
[error] /Users/(Path to project)/project/ScalaTestRunner.scala:66: overloaded method value replace with alternatives:
[error] (java.lang.CharSequence,java.lang.CharSequence)java.lang.String <and>
[error] (Char,Char)java.lang.String
[error] cannot be applied to (java.lang.String, java.lang.String)
[error] private def runPathString(file: File) = file.getAbsolutePath().replace(" ", "\\ ")
[error] ^
[error] four errors found
[error] (compile:compile) Compilation failed
据我了解 sbt 0.12
使用 scala 2.9.2
,它不能正确处理 Java 1.8.当然,降级java是可行的,但这不是解决方案,因为我需要Java 1.8.我已经安装了最新的sbt和scala,但是我觉得这个项目有他自己的sbt什么的.所以,我需要的是专门为这个项目升级 sbt 或降级 java.第二个更受欢迎,因为我担心升级 sbt 会导致我的工作在他们的服务器上失败.我是这方面的新手,所以,如果我说了一些非常愚蠢的话,对不起.
As I understand sbt 0.12
using scala 2.9.2
, that doesn't handle Java 1.8 correctly. Of course, downgrading java works, but it's not a solution, because I need Java 1.8. I have installed latest sbt and scala, but I think this project has his own sbt, or something. So, what I need is upgrade sbt or downgrade java specifically for this project. Second is more preferred, because I'm afraid upgrading sbt can result my work to fail on their servers. I'm a very newbee at this so, if I said something very stupid, sorry.
推荐答案
嘿,其实很简单,如果你知道该怎么做.只需在项目目录中创建 .javaversion
文件(或以上,据我所知,它首先在目录树中搜索)并用 oracle64-1.7.0.76
填充它,或者任何你想.此外,有一个很好的插件,可以让它变得更容易.
Heh, that what was actually very easy, if you know what to do. Just create .javaversion
file in project directory (or above, as I understand, it searches first in dirs tree) and fill it with oracle64-1.7.0.76
, or any you want. Also, there is nice plugin to make it even more easy.
这篇关于如何在项目中更新 sbt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!