Scala project won't compile in Eclipse; “Could not find the main class.”

后端 未结 12 680
暗喜
暗喜 2020-12-03 10:14

I have installed Eclipse 3.5.2 and today\'s Scala plugin from /update-current (that\'s Scala 2.8 final.) I can compile and run Scala projects consisting of a single singleto

相关标签:
12条回答
  • 2020-12-03 11:00

    Make sure that the .class files exist, usually below the bin directory.

    In particular, if you have errors in unrelated files in the same project then the compilation may fail, and no .class files will be produced.

    0 讨论(0)
  • 2020-12-03 11:04

    Do you have a proper build tool setup? Like sbt have you installed it?

    You can check its version by $sbt --version

    If it is not setup you can download from here http://www.scala-sbt.org/download.html

    You might have to restart your eclipse after installation.

    0 讨论(0)
  • 2020-12-03 11:05

    For me, the problem was that there was a build error (see Problems tab) which was preventing compilation; oops! The reason you see the error is that the run macro proceeds despite the failed compilation step, and attempts to run class files it expects to be there; they don't exist because there was a build error preventing compilation, so it says it can't find Main (not compiled).

    Problem goes away when build can complete successfully, i.e. errors are fixed.

    I guess, theoretically, there may be more complicated reasons your build is not completing successfully that are not listed in Problems.

    0 讨论(0)
  • 2020-12-03 11:05

    I had the same error message with a Java application made by myself.

    The problem was that I deleted (though inside Eclipse) a jar that belonged to the Java build path, without deleting it from the Java build path (project's Properties window). When I did it the class could compile and run again.

    0 讨论(0)
  • 2020-12-03 11:06

    There can be the case of projects, containing errors, added to the build path of the application which prevents the completion of successful compilation. Make sure you remove any such project from the build path before running the application.

    Removing these projects solved the problem for me.

    0 讨论(0)
  • 2020-12-03 11:07

    Check scala-ide.log

    For me the issue was that there were errors on:

    AppData\Local\Temp\sbt_10d322fb\xsbt\ClassName.scala:16: error: not found: value enteringPhase enteringPhase(currentRun.flattenPhase.next) { s fullName separator }

    0 讨论(0)
提交回复
热议问题