Linux上运行Scala出现Java异常错误 5C

在Fedora上试图运行Scala,环境变量设置完整,但是出现以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/script/Compilable
at scala.tools.nsc.interpreter.ILoop.createInterpreter(ILoop.scala:126)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:908)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:906)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:906)
at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:906)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

6个回答

运行 scala -version,可正常显示版本信息
Scala code runner version 2.10.6 -- Copyright 2002-2013, LAMP/EPFL

运行scala,出现错误信息:
[ERROR] Failed to construct terminal; falling back to unsupported
java.lang.NumberFormatException: For input string: "0x100"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at java.base/java.lang.Integer.valueOf(Integer.java:983)
at jline.internal.InfoCmp.parseInfoCmp(InfoCmp.java:59)
at jline.UnixTerminal.parseInfoCmp(UnixTerminal.java:233)
at jline.UnixTerminal.(UnixTerminal.java:64)
at jline.UnixTerminal.(UnixTerminal.java:49)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at java.base/java.lang.Class.newInstance(Class.java:558)
at jline.TerminalFactory.getFlavor(TerminalFactory.java:209)
at jline.TerminalFactory.create(TerminalFactory.java:100)
at jline.TerminalFactory.get(TerminalFactory.java:184)
at jline.TerminalFactory.get(TerminalFactory.java:190)
at jline.console.ConsoleReader.(ConsoleReader.java:240)
at jline.console.ConsoleReader.(ConsoleReader.java:232)
at jline.console.ConsoleReader.(ConsoleReader.java:220)
at scala.tools.nsc.interpreter.JLineReader$JLineConsoleReader.(JLineReader.scala:39)
at scala.tools.nsc.interpreter.JLineReader.(JLineReader.scala:21)
at scala.tools.nsc.interpreter.ILoop.chooseReader(ILoop.scala:827)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:846)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:837)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:837)
at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:837)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:83)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

Welcome to Scala version 2.10.6 (Java HotSpot(TM) 64-Bit Server VM, Java 9.0.1).
Type in expressions to have them evaluated.
Type :help for more information.

scala>
Failed to initialize compiler: object scala.runtime in compiler mirror not found.
** Note that as of 2.8 scala does not assume use of the java classpath.
** For the old behavior pass -usejavacp to scala, or if using a Settings
** object programatically, settings.usejavacp.value = true.

Loop.createInterpreter 这说明scala的解释器没有正确创建,可能是配置问题。
http://blog.csdn.net/qq_23617681/article/details/51165531

java中这个包是自动导入的没有说明配置有问题,可以重装一下

应该是某个jar包和javaee的jar包冲突了

1.类名要和JAVA文件同名
2.是否window自动隐藏了文件后缀名,不要隐藏后缀名,把文件后缀改为.JAVA
3.是否import 你需要的包名
4.JAVA的环境变量是否设置正确

字符串转换成int 型的时候出错,原因是 字符串中包含空格,使用.rtim()去除空格

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问