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

后端 未结 12 679
暗喜
暗喜 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 10:43

    I'd solve similar problem by executig "Project->Clean.." with next automatically building.

    0 讨论(0)
  • 2020-12-03 10:45

    I have faced this issue. I have just deleted the package name, created scala class, Written the same code, Set Build to "Build Automatically". Finally, It works perfectly fine.

    0 讨论(0)
  • 2020-12-03 10:48

    If you are using Intellij, mark directory as source root

    0 讨论(0)
  • 2020-12-03 10:49

    Just copy your XXX.scala file code. Remove the package and create a new Scala Class. Paste your XXX.scala code. (If you are using maven, do a maven clean and build.) Run configuration again. This works for me.

    0 讨论(0)
  • 2020-12-03 10:52

    For me it was Eclipse specific problem. I noticed that .class file wasn't built at all. So bin directory doesn't have compiled classes. When I manually compiled *.scala file using *.sbt and copied it to bin directory it was working as expected. I tried different tips and tricks and it wasn't worked until I reinstalled Scala plugin in Eclipse .

    0 讨论(0)
  • 2020-12-03 10:59

    One possibility is that you are trying to launch using ctrl-F11, but from a different class.

    The Scala Eclipse plugin does not obey the defaults for Java launching. In Preferences->Run/Debug->Launching, there are some options Launch Operation->Always Launch the previously selected application, etc. This currently does not work in the Scala eclipse plugin. To launch a specified main, you need to launch it from the editor for the class.

    There has been a bug raised for this. http://scala-ide.assembla.com/spaces/scala-ide/tickets/1000023-scala-launch--does-not-follow-jdt-behaviour

    EDIT: This is now (mostly) fixed.

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