Scala IDE:设置Scala解释器的版本

时间:2016-06-15 15:20:30

标签: scala interpreter scala-ide

我试图为Scala和spark创建类似RStudio的体验。在确定如何在Win7x64上正确安装它(包括Scala 2.10.5)后,我面临问题,那就是解释器的版本

scala> scala.tools.nsc.Properties.versionString
res1: String = version 2.11.8

spark-shell scala版本

不同
scala> scala.tools.nsc.Properties.versionString
res1: String = version 2.10.5

和scala版本(cmd.exe

C:\>scala -version
Scala code runner version 2.10.5 -- Copyright 2002-2013, LAMP,EPFL

当从解释器启动spark时,根据callback hell问题导致我的问题

scala> val sc = new SparkContext(conf)
java.lang.NoSuchMethodError: scala.
collection.immutable.HashSet$.empty()Lscala/collection/immutable/HashSet;

问题:我在哪里设置/配置解释器使用的版本?搜索Scala IDE的全局设置以获得"解释器"没有结果。似乎是与Scala IDE一起发布的东西?

(spark 1.6.1,hadoop 2.6,Scala IDE 4.4.1,Scala 2.10.5,至少应该如此)

1 个答案:

答案 0 :(得分:1)

您可以随时使用scalasbt console文件来启用正确的版本,而不是使用特定的build.sbt REPL安装。

如果您将build.sbt文件添加到主目录,Scala IDE应该选择您要使用的版本。

~/test2$ cat build.sbt
scalaVersion := "2.11.7"
~/test2$ sbt console
[info] Set current project to test2 (in build file:/projects/9ab40ff8-31cd-4860-9cc9-ceb67d1afa39/test2/)
[info] Updating {file:/projects/9ab40ff8-31cd-4860-9cc9-ceb67d1afa39/test2/}test2...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.11.7 (OpenJDK 64-Bit Server VM, Java 1.7.0_101).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :q

[success] Total time: 24 s, completed Jun 16, 2016 9:18:19 PM
~/test2$ echo 'scalaVersion := "2.10.5"' > build.sbt
~/test2$ cat build.sbt
scalaVersion := "2.10.5"
~/test2$ sbt console
[info] Set current project to test2 (in build file:/projects/9ab40ff8-31cd-4860-9cc9-ceb67d1afa39/test2/)
[info] Updating {file:/projects/9ab40ff8-31cd-4860-9cc9-ceb67d1afa39/test2/}test2...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] 'compiler-interface' not yet compiled for Scala 2.10.5. Compiling...
[info]   Compilation completed in 61.292 s
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.5 (OpenJDK 64-Bit Server VM, Java 1.7.0_101).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :q

[success] Total time: 77 s, completed Jun 16, 2016 9:20:45 PM

您还可以从https://www.googleapis.com:22230/等地点指定库依赖项,sbt将下载它们(如果尚未下载)并将它们添加到REPL类路径中。

最后,请查看mvnrepository以获取Scala的Ipython式笔记本界面。