您的位置:首页 > 编程语言 > Java开发

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

2016-07-18 16:11 447 查看
错误: 找不到或无法加载主类 quickanswer.chapter8.p1
Scala project won't compile in Eclipse; “Could not find the main class.”
原因,是项目源代码有错误,eclipse
就不编译其他源代码了,但是 eclipse 左边的树确没有错误的提示,让人以为项目中没有代码方面的错误 但是 eclipse 左边的树确的红叉是怎么消失的? project->clean 操作后,左边树的错误提示就消失了... 这 bug!!!啊  再仔细点发现,消失红叉的是Java文件,如果scala文件出错了还是有红叉提示的
查到http://stackoverflow.com/questions/4449218/mixing-scala-and-java-files-in-an-eclipse-project原来混合java 和scala的不编译的问题已经是世界人民的问题啊

混合java 和scala 不编译的问题 "Project | Clean
http://www.scala-lang.org/old/node/4754.html
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
http://ted-gao.blogspot.com/2011/09/mixing-scala-and-java-in-project.html
至于在eclipse 开发,目前只有自己小心点了吧,保证java和scala编译时不出错哦,如果java文件有错误,再clean,左边java文件的错误提示会消失哦,照成找问题的困难度哦 或者在某些情况可以试试这些操作吧:

调整编译器顺序:右键项目-properties-scala Compiler -Build manager :

set the compile order to JavaThenScala instead of Mixed

关键词:properly general present problem 源代码

--------------------------

以上是转载内容。

注意:我的做法是

右键项目-properties-scala Compiler -Build manager :

set the compile order to JavaThenScala instead of Mixed

scala Library,这里选择scala-2.10.5版本

弄好后clean项目。检查problem下面没有报错,然后就可以正常运行了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  scala eclipse