查看报错信息
[ERROR] Failed to construct terminal; falling back to unsupported
java.io.IOException: Cannot run program "sh": CreateProcess error=2, 系统找不到指定的文件。
点击查看代码
27/04/2024 18:52.17 /home/mobaxterm scala
Welcome to Scala 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 22.0.1).
Type in expressions for evaluation. Or try :help.
[ERROR] Failed to construct terminal; falling back to unsupported
java.io.IOException: Cannot run program "sh": CreateProcess error=2, 系统找不到指定的文件。
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1089)
at jline.internal.TerminalLineSettings.exec(TerminalLineSettings.java:308)
at jline.internal.TerminalLineSettings.stty(TerminalLineSettings.java:282)
at jline.internal.TerminalLineSettings.get(TerminalLineSettings.java:143)
at jline.internal.TerminalLineSettings.<init>(TerminalLineSettings.java:108)
at jline.internal.TerminalLineSettings.getSettings(TerminalLineSettings.java:123)
at jline.UnixTerminal.<init>(UnixTerminal.java:60)
at jline.UnixTerminal.<init>(UnixTerminal.java:50)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:132)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:259)
at java.base/java.lang.Class.newInstance(Class.java:755)
at jline.TerminalFactory.getFlavor(TerminalFactory.java:211)
at jline.TerminalFactory.getFlavor(TerminalFactory.java:196)
at jline.TerminalFactory.create(TerminalFactory.java:82)
at jline.TerminalFactory.get(TerminalFactory.java:186)
at jline.TerminalFactory.get(TerminalFactory.java:192)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:243)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:235)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:223)
at scala.tools.nsc.interpreter.jline.JLineConsoleReader.<init>(JLineReader.scala:64)
at scala.tools.nsc.interpreter.jline.InteractiveReader.<init>(JLineReader.scala:33)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
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$22$$anonfun$apply$10.apply(ILoop.scala:873)
at scala.tools.nsc.interpreter.ILoop$$anonfun$22$$anonfun$apply$10.apply(ILoop.scala:873)
at scala.util.Try$.apply(Try.scala:192)
at scala.tools.nsc.interpreter.ILoop$$anonfun$22.apply(ILoop.scala:873)
at scala.tools.nsc.interpreter.ILoop$$anonfun$22.apply(ILoop.scala:873)
at scala.collection.immutable.Stream.map(Stream.scala:418)
at scala.tools.nsc.interpreter.ILoop.chooseReader(ILoop.scala:873)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1$$anonfun$newReader$1$1.apply(ILoop.scala:893)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.newReader$1(ILoop.scala:893)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.scala$tools$nsc$interpreter$ILoop$$anonfun$$preLoop$1(ILoop.scala:897)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1$$anonfun$startup$1$1.apply(ILoop.scala:964)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:990)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:891)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:891)
at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:891)
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)
Caused by: java.io.IOException: CreateProcess error=2, 系统找不到指定的文件。
at java.base/java.lang.ProcessImpl.create(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:500)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1126)
... 50 more
scala>
解决方法
在cmd后面加上 c:/
27/04/2024 18:54.47 /home/mobaxterm cmd c:/
Microsoft Windows [版本 10.0.22631.3447]
(c) Microsoft Corporation。保留所有权利。
C:\Users\hmmm\AppData\Local\Temp\Mxt222\tmp\home_hmmm>scala
Welcome to Scala 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 22.0.1).
Type in expressions for evaluation. Or try :help.
scala> var x = 2+2
x: Int = 4
scala> // 成功
标签:java,ILoop,scala,mobaxten,nsc,报错,interpreter,tools
From: https://www.cnblogs.com/humlogs/p/18162367