尝试使用scala插件在IDEA中使用scala:
我的HelloWorld对象:
object HelloWorld { def main(args: Array[String]) { println("Hello") } }
而有时我从上下文菜单中按下"运行的HelloWorld"当得到一个错误.
scalac: Error: Could not find an output directory for /Users/username/Work/src/sandbox/src/HelloWorld.scala in List((/Users/username/work/src/sandbox/src,/Users/username/work/src/sandbox/out/production/sandbox)) scala.reflect.internal.FatalError: Could not find an output directory for /Users/username/Work/src/sandbox/src/HelloWorld.scala in List((/Users/username /work/src/sandbox/src,/Users/username/work/src/sandbox/out/production/sandbox)) at scala.tools.nsc.settings.MutableSettings$OutputDirs.outputDirFor(MutableSettings.scala:303) at scala.tools.nsc.backend.jvm.BytecodeWriters$class.outputDirectory(BytecodeWriters.scala:26) at scala.tools.nsc.backend.jvm.BytecodeWriters$class.scala$tools$nsc$backend$jvm$BytecodeWriters$$getFile(BytecodeWriters.scala:37) at scala.tools.nsc.backend.jvm.BytecodeWriters$ClassBytecodeWriter$class.writeClass(BytecodeWriters.scala:89) at scala.tools.nsc.backend.jvm.GenASM$AsmPhase$$anon$4.writeClass(GenASM.scala:67) at scala.tools.nsc.backend.jvm.GenASM$JBuilder.writeIfNotTooBig(GenASM.scala:458) at scala.tools.nsc.backend.jvm.GenASM$JMirrorBuilder.genMirrorClass(GenASM.scala:2954) at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:113) at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1583) at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1557) at scala.tools.nsc.Global$Run.compileSources(Global.scala:1553) at scala.tools.nsc.Global$Run.compile(Global.scala:1662) at xsbt.CachedCompiler0.run(CompilerInterface.scala:126) at xsbt.CachedCompiler0.run(CompilerInterface.scala:102) at xsbt.CompilerInterface.run(CompilerInterface.scala:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102) at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48) at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41) at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:26) at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:25) at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:58) at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:21) at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
这个错误非常烦人,因为修复它我需要重新启动IDEA,清理/编译我的项目,添加/删除启动配置几次.也可以手动从终端执行正确的错误命令行.
看错误评论:
找不到以下输出目录:
/Users/username/Work /src/sandbox/src/HelloWorld.scala在
/ Users/username/work/src/sandbox/src
/ Users/username/work/src/sandbox/out/production/sandbox
根据您运行的环境,上/下案例差异中的IntelliJ很重要.请确保您的user.home属性设置正确.