开发者

Why does console in IDEA 10 fail with "tools is not a member of package scala"?

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=U开发者_开发问答TF-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


Add the scala-compiler.jar (or scala-compiler-2.x.y global library) to your module's dependencies


Add -usejavacp to your console arguments (in run -> edit configurations).


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜