REPL does not show input

霸气de小男生 提交于 2019-12-11 15:49:48

问题


I'm trying to write some Scala code in the Scala interpreter, using the following steps. I'm using Windows.

  1. Open command prompt and go to project root directory
  2. Type sbt then console to start Scala REPL
  3. It opens the Scala REPL with below message

Message:

D:\example\example>sbt
"C:\Users\rajnish.kumar\.sbt\preloaded\org.scala-sbt\sbt\"1.0.4"\jars\sbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from D:\example\example\project
[info] Set current project to bigdata-example (in build file:/D:/example/example/)

> console
[info] Starting scala interpreter...
[info]
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.NoClassDefFoundError: Could not initialize class scala.tools.fusesource_embedded.jansi.internal.Kernel32
        at scala.tools.fusesource_embedded.jansi.internal.WindowsSupport.getConsoleMode(WindowsSupport.java:50)
        at scala.tools.jline_embedded.WindowsTerminal.getConsoleMode(WindowsTerminal.java:204)
        at scala.tools.jline_embedded.WindowsTerminal.init(WindowsTerminal.java:82)
        at scala.tools.jline_embedded.TerminalFactory.create(TerminalFactory.java:101)
        at scala.tools.jline_embedded.TerminalFactory.get(TerminalFactory.java:158)
        at scala.tools.jline_embedded.console.ConsoleReader.<init>(ConsoleReader.java:229)
        at scala.tools.jline_embedded.console.ConsoleReader.<init>(ConsoleReader.java:221)
        at scala.tools.jline_embedded.console.ConsoleReader.<init>(ConsoleReader.java:209)
        at scala.tools.nsc.interpreter.jline_embedded.JLineConsoleReader.<init>(JLineReader.scala:62)
        at scala.tools.nsc.interpreter.jline_embedded.InteractiveReader.<init>(JLineReader.scala:34)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$scala$tools$nsc$interpreter$ILoop$$instantiater$1$1.apply(ILoop.scala:858)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$scala$tools$nsc$interpreter$ILoop$$instantiater$1$1.apply(ILoop.scala:855)
        at scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$mkReader$1(ILoop.scala:862)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$21$$anonfun$apply$9.apply(ILoop.scala:873)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$21$$anonfun$apply$9.apply(ILoop.scala:873)
        at scala.util.Try$.apply(Try.scala:192)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$21.apply(ILoop.scala:873)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$21.apply(ILoop.scala:873)
        at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:418)
        at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:418)
        at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1233)
        at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1223)
        at scala.collection.immutable.Stream.collect(Stream.scala:435)
        at scala.tools.nsc.interpreter.ILoop.chooseReader(ILoop.scala:875)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1$$anonfun$apply$mcZ$sp$2.apply(ILoop.scala:914)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:914)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:909)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:909)
        at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)
        at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:909)
        at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:934)
        at xsbt.ConsoleInterface.run(ConsoleInterface.scala:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101)
        at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:76)
        at sbt.Console.sbt$Console$$console0$1(Console.scala:22)
        at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:23)
        at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        at sbt.Logger$$anon$4.apply(Logger.scala:85)
        at sbt.TrapExit$App.run(TrapExit.scala:248)
        at java.lang.Thread.run(Thread.java:748)

Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_151).
Type in expressions for evaluation. Or try :help.

scala>

Now when I type anything (e.g. val s = 30) it do not appears in the command window. But when I hit enter it displays scala> s: Int = 30

My Scala version is 2.11.8.

来源:https://stackoverflow.com/questions/47866332/repl-does-not-show-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!