`
zhouchaofei2010
  • 浏览: 1083077 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Scala eclipse 错误 -找不到或无法加载主类

阅读更多
错误: 找不到或无法加载主类 quickanswer.chapter8.p1
 

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

 
 
原因,是项目中源代码有错误,eclipse 就不编译其他源代码了,但是 eclipse 左边的树确没有错误的提示,让人以为项目中没有代码方面的错误
 
但是 eclipse 左边的树确的红叉是怎么消失的?
 
 
 
project->clean 操作后,左边树的错误提示就消失了...   这  bug!!!啊 
 
 
再仔细点发现,消失红叉的是java文件,如果scala文件出错了还是有红叉提示的
 
原来混合java 和scala的不编译的问题已经是世界人民的问题啊
 
 
混合java 和scala 不编译的问题   "Project | Clean
It's a tricky one: solving this properly requires deeper cooperation
between the Scala and Java compilers than is present at the moment.
IMO the best line of attack is a more general one which addresses the
joint-compilation problem for all JVM languages that want to play ...
there's been some discussion of this on the JVM languages list
recently,(解决这个问题需要更深层次的scala和java编译器之间的合作)
 
 
 joint compile java  scala  mix 混合编译的解决办法 是用maven,在maven 里配置编译顺序 ,先scala后java  或者 先java后scala
 
 不过,最新版(

Version 4.2.0

)是这么介绍的

Features

Support for Mixed Scala/Java Projects

Support for mixed Scala/Java projects and any combination of Scala/Java project dependencies, allowing straightforward references from Scala to Java and vice versa.
所以呢,不是eclipse 不支持混合java 和 scala  ,只是支持的还不是很好,还是有bug 的
 
测试了另外一个IDE工具IntelliJ IDEA 14.1,没有如上问题,很完美 perfect! 
 
至于在eclipse 开发,目前只有自己小心点了吧,保证java和scala编译时不出错哦,如果java文件有错误,再clean,左边java文件的错误提示会消失哦,照成找问题的困难度哦
 
期待scala eclipse plugin 的下一个版本吧 
 
 
或者在某些情况可以试试这些操作吧:
调整编译器顺序:右键项目-properties-scala Compiler -Build manager  :  set the compile order to JavaThenScala instead of Mixed

 

1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics