为什么 IDEA 10 中的控制台失败并显示“工具不是 scala 包的成员”?
我安装了最新的 IntelliJ (10.0.1) 和 Scala 插件。
每当我在控制台中运行某些内容时,都会收到错误。
这是一个示例(我尝试加载一些 scala 文件)
"C:\Program Files\Java\jdk1.6.0_05\bin\java"
-Didea.launcher.port=7533 "-Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 10.0.1\bin"
-Dfile.encoding=UTF-8
-classpath "C:\`development\scala\lib\scala-compiler.jar;C:\`development\scalalib\scala-library.jar;C:\Documents and Settings\alex.repede\.IntelliJIdea10\config\plugins\Scala\lib\scala-plugin-runners.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 10.0.1\lib\idea_rt.jar"
com.intellij.rt.execution.application.AppMain
通过:
org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner
-classpath "C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/localedata.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/management-agent.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/plugin.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/resources.jar;C:/`development/scala/lib/scala-swing.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/sunmscapi.jar;
C:/Program Files/Java/jdk1.6.0_05/jre/lib/deploy.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/jsse.jar;C:/`development/scala/lib/scala-dbc.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/dnsns.jar;C:/`development/scala/lib/scala-library.jar;
C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/sunpkcs11.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/javaws.jar;
C:/Program Files/Java/jdk1.6.0_05/jre/lib/jce.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/rt.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/sunjce_provider.jar;
C:/Program Files/Java/jdk1.6.0_05/jre/lib/charsets.jar;"
给出:
Welcome to Scala version 2.8.1.final
(Java HotSpot(TM) Client VM, Java 1.6.0_05). Type in expressions to have them evaluated. Type :help for more information.
scala> :load
c:/`playspace/FirstScala/first.scala
Loading
c:\`playspace\FirstScala\first.scala...
x: Int = 4 <script>:3: error: value
tools is not a member of package scala
var value:
scala.tools.nsc.InterpreterSettings =
_
^ <script>:4: error: value tools is not a member of
package scala def set(x: Any) =
value =
x.asInstanceOf[scala.tools.nsc.InterpreterSettings]
^ Exception in thread "main"
java.util.NoSuchElementException:
None.get at
scala.None$.get(Option.scala:262) at
scala.None$.get(Option.scala:260) at
scala.tools.nsc.Interpreter.bind(Interpreter.scala:624)
at
scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:632)
at
scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:632)
at
scala.tools.nsc.Interpreter$$anonfun$beQuietDuring$2.apply(Interpreter.scala:171)
at
scala.util.control.Exception$Catch.apply(Exception.scala:79)
at
scala.tools.nsc.Interpreter.beQuietDuring(Interpreter.scala:169)
at
scala.tools.nsc.Interpreter.quietBind(Interpreter.scala:632)
at
scala.tools.nsc.Interpreter.recordRequest(Interpreter.scala:278)
at
scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:586)
at
scala.tools.nsc.Interpreter.interpret(Interpreter.scala:599)
at
scala.tools.nsc.Interpreter.interpret(Interpreter.scala:577)
at
scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:472)
at
scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:515)
at
scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:362)
at
scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:243)
at
scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:249)
at
scala.tools.nsc.InterpreterLoop$$anonfun$interpretAllFrom$1.apply(InterpreterLoop.scala:260)
at
scala.tools.nsc.InterpreterLoop$$anonfun$interpretAllFrom$1.apply(InterpreterLoop.scala:257)
at
scala.tools.nsc.io.Streamable$Chars$class.applyReader(Streamable.scala:100)
> at
scala.tools.nsc.io.File.applyReader(File.scala:62)
at
scala.tools.nsc.InterpreterLoop.interpretAllFrom(InterpreterLoop.scala:257)
at
scala.tools.nsc.InterpreterLoop$$anonfun$load$1.apply(InterpreterLoop.scala:303)
at
scala.tools.nsc.InterpreterLoop$$anonfun$load$1.apply(InterpreterLoop.scala:302)
at
scala.tools.nsc.InterpreterLoop.withFile(InterpreterLoop.scala:296)
at
scala.tools.nsc.InterpreterLoop.load(InterpreterLoop.scala:302)
at
scala.tools.nsc.InterpreterLoop$$anonfun$7.apply(InterpreterLoop.scala:204)
at
scala.tools.nsc.InterpreterLoop$$anonfun$7.apply(InterpreterLoop.scala:204)
at
scala.tools.nsc.InterpreterControl$OneArg.apply(InterpreterLoop.scala:53)
at
scala.tools.nsc.InterpreterControl$OneArg.apply(InterpreterLoop.scala:50)
at
scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:373)
at
scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:243)
at
scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:249)
at
scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:559)
at
scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:610)
at
org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:33)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
Process finished with exit code 1
这个控制台有什么问题?
这是另一个示例:
scala> val x = 5
x: Int = 5
<script>:3: error: value tools is not a member of package scala
var value: scala.tools.nsc.InterpreterSettings = _
^
<script>:4: error: value tools is not a member of package scala
def set(x: Any) = value = x.asInstanceOf[scala.tools.nsc.InterpreterSettings]
^
Exception in thread "main" java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:262)
at scala.None$.get(Option.scala:260)
at scala.tools.nsc.Interpreter.bind(Interpreter.scala:624)
at scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:632)
at scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:632)
at scala.tools.nsc.Interpreter$$anonfun$beQuietDuring$2.apply(Interpreter.scala:171)
at scala.util.control.Exception$Catch.apply(Exception.scala:79)
at scala.tools.nsc.Interpreter.beQuietDuring(Interpreter.scala:169)
at scala.tools.nsc.Interpreter.quietBind(Interpreter.scala:632)
at scala.tools.nsc.Interpreter.recordRequest(Interpreter.scala:278)
at scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:586)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:599)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:577)
at scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:472)
at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:515)
at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:362)
at scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:243)
at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:249)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:559)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:610)
at org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
Process finished with exit code 1
I have latest IntelliJ installed (10.0.1) with the Scala plugin.
Whenever I run something in a console, I get an error.
Here is an example (I tried to load some scala file)
"C:\Program Files\Java\jdk1.6.0_05\bin\java"
-Didea.launcher.port=7533 "-Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 10.0.1\bin"
-Dfile.encoding=UTF-8
-classpath "C:\`development\scala\lib\scala-compiler.jar;C:\`development\scalalib\scala-library.jar;C:\Documents and Settings\alex.repede\.IntelliJIdea10\config\plugins\Scala\lib\scala-plugin-runners.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 10.0.1\lib\idea_rt.jar"
com.intellij.rt.execution.application.AppMain
Through:
org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner
-classpath "C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/localedata.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/management-agent.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/plugin.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/resources.jar;C:/`development/scala/lib/scala-swing.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/sunmscapi.jar;
C:/Program Files/Java/jdk1.6.0_05/jre/lib/deploy.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/jsse.jar;C:/`development/scala/lib/scala-dbc.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/dnsns.jar;C:/`development/scala/lib/scala-library.jar;
C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/sunpkcs11.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/javaws.jar;
C:/Program Files/Java/jdk1.6.0_05/jre/lib/jce.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/rt.jar;C:/Program Files/Java/jdk1.6.0_05/jre/lib/ext/sunjce_provider.jar;
C:/Program Files/Java/jdk1.6.0_05/jre/lib/charsets.jar;"
gives:
Welcome to Scala version 2.8.1.final
(Java HotSpot(TM) Client VM, Java 1.6.0_05). Type in expressions to have them evaluated. Type :help for more information.
scala> :load
c:/`playspace/FirstScala/first.scala
Loading
c:\`playspace\FirstScala\first.scala...
x: Int = 4 <script>:3: error: value
tools is not a member of package scala
var value:
scala.tools.nsc.InterpreterSettings =
_
^ <script>:4: error: value tools is not a member of
package scala def set(x: Any) =
value =
x.asInstanceOf[scala.tools.nsc.InterpreterSettings]
^ Exception in thread "main"
java.util.NoSuchElementException:
None.get at
scala.None$.get(Option.scala:262) at
scala.None$.get(Option.scala:260) at
scala.tools.nsc.Interpreter.bind(Interpreter.scala:624)
at
scala.tools.nsc.Interpreter$anonfun$quietBind$1.apply(Interpreter.scala:632)
at
scala.tools.nsc.Interpreter$anonfun$quietBind$1.apply(Interpreter.scala:632)
at
scala.tools.nsc.Interpreter$anonfun$beQuietDuring$2.apply(Interpreter.scala:171)
at
scala.util.control.Exception$Catch.apply(Exception.scala:79)
at
scala.tools.nsc.Interpreter.beQuietDuring(Interpreter.scala:169)
at
scala.tools.nsc.Interpreter.quietBind(Interpreter.scala:632)
at
scala.tools.nsc.Interpreter.recordRequest(Interpreter.scala:278)
at
scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:586)
at
scala.tools.nsc.Interpreter.interpret(Interpreter.scala:599)
at
scala.tools.nsc.Interpreter.interpret(Interpreter.scala:577)
at
scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:472)
at
scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:515)
at
scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:362)
at
scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:243)
at
scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:249)
at
scala.tools.nsc.InterpreterLoop$anonfun$interpretAllFrom$1.apply(InterpreterLoop.scala:260)
at
scala.tools.nsc.InterpreterLoop$anonfun$interpretAllFrom$1.apply(InterpreterLoop.scala:257)
at
scala.tools.nsc.io.Streamable$Chars$class.applyReader(Streamable.scala:100)
> at
scala.tools.nsc.io.File.applyReader(File.scala:62)
at
scala.tools.nsc.InterpreterLoop.interpretAllFrom(InterpreterLoop.scala:257)
at
scala.tools.nsc.InterpreterLoop$anonfun$load$1.apply(InterpreterLoop.scala:303)
at
scala.tools.nsc.InterpreterLoop$anonfun$load$1.apply(InterpreterLoop.scala:302)
at
scala.tools.nsc.InterpreterLoop.withFile(InterpreterLoop.scala:296)
at
scala.tools.nsc.InterpreterLoop.load(InterpreterLoop.scala:302)
at
scala.tools.nsc.InterpreterLoop$anonfun$7.apply(InterpreterLoop.scala:204)
at
scala.tools.nsc.InterpreterLoop$anonfun$7.apply(InterpreterLoop.scala:204)
at
scala.tools.nsc.InterpreterControl$OneArg.apply(InterpreterLoop.scala:53)
at
scala.tools.nsc.InterpreterControl$OneArg.apply(InterpreterLoop.scala:50)
at
scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:373)
at
scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:243)
at
scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:249)
at
scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:559)
at
scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:610)
at
org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:33)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
Process finished with exit code 1
What's wrong with this console ?
Here is another example :
scala> val x = 5
x: Int = 5
<script>:3: error: value tools is not a member of package scala
var value: scala.tools.nsc.InterpreterSettings = _
^
<script>:4: error: value tools is not a member of package scala
def set(x: Any) = value = x.asInstanceOf[scala.tools.nsc.InterpreterSettings]
^
Exception in thread "main" java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:262)
at scala.None$.get(Option.scala:260)
at scala.tools.nsc.Interpreter.bind(Interpreter.scala:624)
at scala.tools.nsc.Interpreter$anonfun$quietBind$1.apply(Interpreter.scala:632)
at scala.tools.nsc.Interpreter$anonfun$quietBind$1.apply(Interpreter.scala:632)
at scala.tools.nsc.Interpreter$anonfun$beQuietDuring$2.apply(Interpreter.scala:171)
at scala.util.control.Exception$Catch.apply(Exception.scala:79)
at scala.tools.nsc.Interpreter.beQuietDuring(Interpreter.scala:169)
at scala.tools.nsc.Interpreter.quietBind(Interpreter.scala:632)
at scala.tools.nsc.Interpreter.recordRequest(Interpreter.scala:278)
at scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:586)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:599)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:577)
at scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:472)
at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:515)
at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:362)
at scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:243)
at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:249)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:559)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:610)
at org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
Process finished with exit code 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
scala-compiler.jar
(或scala-compiler-2.xy
全局库)添加到模块的依赖项中Add the
scala-compiler.jar
(orscala-compiler-2.x.y
global library) to your module's dependencies将 -usejavacp 添加到控制台参数(在运行 -> 编辑配置中)。
Add -usejavacp to your console arguments (in run -> edit configurations).
对于 IntelliJ 12.1.4。右键单击项目->选择“添加框架支持...”->选择Scala
当Scala不可用时,安装插件 设置->插件 ->安装 JetBrains 插件...->搜索斯卡拉
For IntelliJ 12.1.4. Right click on project -> select "Add Framework Support..." -> Select Scala
When Scala is not is not available, install plugin Settings -> Plugins -> Install JetBrains Plugin ... -> search for Scala