<tfoot id='vh6V4'></tfoot>
<legend id='vh6V4'><style id='vh6V4'><dir id='vh6V4'><q id='vh6V4'></q></dir></style></legend>

      <small id='vh6V4'></small><noframes id='vh6V4'>

      1. <i id='vh6V4'><tr id='vh6V4'><dt id='vh6V4'><q id='vh6V4'><span id='vh6V4'><b id='vh6V4'><form id='vh6V4'><ins id='vh6V4'></ins><ul id='vh6V4'></ul><sub id='vh6V4'></sub></form><legend id='vh6V4'></legend><bdo id='vh6V4'><pre id='vh6V4'><center id='vh6V4'></center></pre></bdo></b><th id='vh6V4'></th></span></q></dt></tr></i><div id='vh6V4'><tfoot id='vh6V4'></tfoot><dl id='vh6V4'><fieldset id='vh6V4'></fieldset></dl></div>

          <bdo id='vh6V4'></bdo><ul id='vh6V4'></ul>

        Scala 项目不会在 Eclipse 中编译;“找不到主类."

        Scala project won#39;t compile in Eclipse; quot;Could not find the main class.quot;(Scala 项目不会在 Eclipse 中编译;“找不到主类.)
          <tbody id='7fZ8g'></tbody>
          <i id='7fZ8g'><tr id='7fZ8g'><dt id='7fZ8g'><q id='7fZ8g'><span id='7fZ8g'><b id='7fZ8g'><form id='7fZ8g'><ins id='7fZ8g'></ins><ul id='7fZ8g'></ul><sub id='7fZ8g'></sub></form><legend id='7fZ8g'></legend><bdo id='7fZ8g'><pre id='7fZ8g'><center id='7fZ8g'></center></pre></bdo></b><th id='7fZ8g'></th></span></q></dt></tr></i><div id='7fZ8g'><tfoot id='7fZ8g'></tfoot><dl id='7fZ8g'><fieldset id='7fZ8g'></fieldset></dl></div>
          • <legend id='7fZ8g'><style id='7fZ8g'><dir id='7fZ8g'><q id='7fZ8g'></q></dir></style></legend>
            • <bdo id='7fZ8g'></bdo><ul id='7fZ8g'></ul>

              <small id='7fZ8g'></small><noframes id='7fZ8g'>

            • <tfoot id='7fZ8g'></tfoot>

                  本文介绍了Scala 项目不会在 Eclipse 中编译;“找不到主类."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经从/update-current 安装了 Eclipse 3.5.2 和今天的 Scala 插件(即 Scala 2.8 final).我可以编译和运行由实现 main() 的单个单例对象组成的 Scala 项目.

                  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 singleton object that implements main().

                  但是,如果项目包含更多类,我会收到找不到主类"错误.

                  But, if a project contains more classes, I receive the "Could not find the main class" error.

                  我已经尝试搜索解决方案,我发现:

                  I have tried searching for the solution and I discovered:

                  Eclipse 正在正确查找 Main$ 类,而不是 Main 类
                  * 在调试配置下,我的主类被正确识别为 mypackage.Main
                  * 我的插件是最新的,推荐用于我的 Eclipse 版本
                  * 清理、重启等无济于事.

                  Eclipse is correctly looking for the Main$ class, not the Main class
                  * under Debug Configurations, my main class is correctly identified as mypackage.Main
                  * my plugin is up to date and recommended for my version of Eclipse
                  * cleaning, restarting etc. doesn't help.

                  同一个项目将使用 scalac 编译.

                  The same project will compile with scalac.

                  感谢您提供有关如何解决此问题的任何想法.

                  Thanks for any ideas on how to solve this.

                  MatthieuF 建议我应该发布代码.

                  MatthieuF suggested I should post the code.

                  此代码段会产生错误.这不是最惯用的代码,但我这样写是为了测试我的环境.我将其作为单个文件和单独的文件进行了尝试.它确实适用于 scalac.

                  This snippet produces an error. It's not the most idiomatic code, but I wrote it that way to test my environment. I tried it as a single file and as separate files. It DOES work with scalac.

                  import swing._
                  
                  class HelloFrame extends Frame {
                          title = "First program"
                          contents = new Label("Hello, world!")
                  }
                  
                  object Hello {
                    val frame = new HelloFrame    
                    def main(args : Array[String]) : Unit = {
                          frame.visible = true
                     }
                  }
                  

                  但是,如果我将 HelloFrame 的定义嵌套在 Hello 中,它就可以工作.此代码段完美运行:

                  BUT, if I nest the definition of HelloFrame within Hello, it works. This snippet runs perfectly:

                  import swing._
                  
                  object Hello {
                  
                      class HelloFrame extends Frame {
                          title = "First program"
                          contents = new Label("Hello, world!")
                      }
                  
                      val frame = new HelloFrame
                  
                      def main(args : Array[String]) : Unit = {
                          frame.visible = true
                      }
                  }
                  

                  推荐答案

                  对我来说,问题是存在阻止编译的构建错误(请参阅问题"选项卡);哎呀!您看到错误的原因是尽管编译步骤失败,运行宏仍在继续,并尝试运行它期望存在的类文件;它们不存在,因为存在阻止编译的构建错误,所以它说它找不到 Main(未编译).

                  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.

                  这篇关于Scala 项目不会在 Eclipse 中编译;“找不到主类."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                  How can I specify the default JVM arguments for programs I run from eclipse?(如何为从 Eclipse 运行的程序指定默认 JVM 参数?)
                  Class JavaLaunchHelper is implemented in both ... libinstrument.dylib. One of the two will be used. Which one is undefined(JavaLaunchHelper 类在... libinstrument.dylib 中都实现了.将使用两者之一.哪个是未定义的) - IT屋-程序员软件开发技术分享
                  Does the JVM prevent tail call optimizations?(JVM 会阻止尾调用优化吗?)
                  Running Eclipse on Windows 7 JRE and JDK not found(找不到在 Windows 7 JRE 和 JDK 上运行 Eclipse)
                  StringBuilder vs. .concat vs. quot;+quot; Operator relative performance different in eclipse than command line?(StringBuilder vs. .concat vs. “+eclipse中的操作员相对性能与命令行不同?)
                1. <tfoot id='MoA4X'></tfoot>

                  <legend id='MoA4X'><style id='MoA4X'><dir id='MoA4X'><q id='MoA4X'></q></dir></style></legend>

                      <tbody id='MoA4X'></tbody>

                          <i id='MoA4X'><tr id='MoA4X'><dt id='MoA4X'><q id='MoA4X'><span id='MoA4X'><b id='MoA4X'><form id='MoA4X'><ins id='MoA4X'></ins><ul id='MoA4X'></ul><sub id='MoA4X'></sub></form><legend id='MoA4X'></legend><bdo id='MoA4X'><pre id='MoA4X'><center id='MoA4X'></center></pre></bdo></b><th id='MoA4X'></th></span></q></dt></tr></i><div id='MoA4X'><tfoot id='MoA4X'></tfoot><dl id='MoA4X'><fieldset id='MoA4X'></fieldset></dl></div>

                          <small id='MoA4X'></small><noframes id='MoA4X'>

                            <bdo id='MoA4X'></bdo><ul id='MoA4X'></ul>