Main method is not found in class...

I'm getting "Main method is not found in class... " compiler error on simple projects which worked a week ago. Currently I have the latest IDE and latest plugin an recently installed Scala 2.7.2.RC1.
Scala interpreter works fine. Scala facet was set during project creation as usual. I tried to create a new simple project and got this error. I was able to run existing project until I hit "Edit Configuration" -> OK. Then I started to receive the same main method is not found. Projects are as simple as

package multitable

/**

  • Created by IntelliJ IDEA.

  • User: vkelman

  • Date: Aug 2, 2008

  • Time: 4:19:20 AM

  • To change this template use File | Settings | File Templates.

*/

object MultiTable {
def main(args: Array[String]) {
val multi = {
val table = for (i <- 1 to 10) yield {
val row = for (j <- 1 to 10) yield {
val prod = (i * j).toString
String.format("%4s", Array(prod))
}
row.mkString + "\n"
}
table.mkString
}

println(multi)
}

Main class is specified as multitable.MultiTable. It worked before, but does not work any more. Eclipse plug-in works fine.

After reading another thread here I tried to set main type explicitly like

def main(args: Array[String]): Unit = { ...}

A red cross in the run configuration combo box disappeared and "Warning: Main method not found in class ..." disappeared, but I'm still getting Compiler internal error.

By the way, def main(args: Array[String]) { ...} form is supposed to work as well. It works in Netbeans and Eclipse, and Martin Odersky said in his book that omission
of "=" sign automatically and always lead to Unit type, even if other type was explicitly specified.

Edited by: Vladimir Kelman on Aug 28, 2008 8:02 AM

15 comments
Comment actions Permalink

I think you are getting "main method not found" not from the compiler, but from IDEA when it tries to run your program. Please make sure you have a class compiled on disk. For example this issue could be caused by "make before run" option unticked in run configuration, but I believe there could be other issues, none of which are scala-plugin specific.
Eugene.

P.S. scala procedures returning Unit issue has been fixed

0
Comment actions Permalink

You know, "Make before launch"is checked. However, on all Scala projects it either says that main is not found or just "Compiler internal error" - no details.
I tried to uninstall and re-install Diana IDE - it didn't make any difference. I must be doing something stupid, but as far as I remember the same thing worked fine until recent upgrades.
Please look at Picture1[/url] and Picture2[/url]

Before installing Diana I had latest 8M1 release (or whatever it is called).

0
Comment actions Permalink

after upgrading to new plugin version I also get "compiler internal error" occasionally. We will investigate it ASAP, and if you could provide a self-contained example where the problem is reproducible, that would help us a lot.

0
Comment actions Permalink

Hi Eugene! I'd be glad to help. What exactly do I need to send you? I can zip a couple of folders with simple projects which give me that error and send ZIP file to you (I cannot attach a file here, or can I?).
I'm using Win XP machine (does it matter?) and I wonder if some ItelliJ IDEA settings in Application Data folder would mater. There maybe something left from a previous version of IntelliJ IDEA....

(I'm not doing any real development in Scala yet, I'm just learning and I have Eclipse and Netbeans IDEs working, so there is no emergency to me.)

0
Comment actions Permalink

Hello, Vladimir.
Yes, it does matter on what OS your Scala compiler has been lanched because of some troubles related to stack size. From our experience, on Windows scala compiler demands more stack space then on unix-based systems. Otherwise, that could be an error, induced by our intermediate compiler implementation.
If you have liite example to reproduce this behavior, please, send it to me.
Thanks.

WBR,
Ilya

0
Comment actions Permalink

Hi! I just sent you a small sample.
In fact every application now produces that Scala compiler error on my machine. When I updated IntelliJ IDEA for last several times, I did check "remove history" or "local files" - whatever it asks me to check or not to check, I forgot exact options. Now I'm going to try to wipe out IntelliJ IDEA from my system completely and to install clean latest DIANA EAP.

0
Comment actions Permalink

I was having the same problem with the latest Diana and Scala plugin EAP
builds together with Scala 2.7.2 RC1.
However updating to the latest Scala nightly build and all seems well.

0
Comment actions Permalink

Yes, I have Scala 2.7.2 RC1 too. I'll try to install a latest night build, thank you.

0
Comment actions Permalink

Hello, Vladimir.

Since I don't know what kind of error you received, I cannot say, is it "pure" scalac error, or our plugin's. In next version of plugin output in such cases will be much more verbose. As I know, there was many bugs in 2.7.2RC1 compiler, and I submitted some of them to Scala bugtracker. They could be already fixed in last Scala builds.

Ilya

0
Comment actions Permalink

I decided to give a last try to 2.7.2RC1 before switching to nightly builds of Scala, uninstalled Diana together with local settings and plugins, installed the latest #8769 and ... either I forgot how to install Scala plugin or something changed. Diana's Plugin Manager shows only Scala 4440 Jan 5, 2008 as available plugin. Could you please remind me how to install the latest 0.2.18767 plugin?

0
Comment actions Permalink

We've just uploaded last plugin version for new EAP to our plugin repository.

Ilya

0
Comment actions Permalink

I installed latest Scala plugin. Unfortunately, it didn't make any difference: I'm still getting "Compiler internal error". So, I'm going to install a latest nightly build of Scala, as Steve suggested, in hope to fix things.

0
Comment actions Permalink

Steve (or someone else), could you please guide me on how to install a nightly build of Scala?
I'm on WinXP machine. Currently, I have Scala 2.7.2 RC1 installed using IzPack Installer (http://www.scala-lang.org/downloads).
Should I uninstall it before installation of the latest nightly build?
What is a correct file to download from http://www.scala-lang.org/node/212 ? Is it scala-2.7.2.latest.zip or maybe scala-2.7.2.r16085-b20080910010136.zip (or is it currently the same?)
Should I just extract files from ZIP archive and replace existing Scala files correspondingly?

Thank you

0
Comment actions Permalink

To install it I just downloaded and unzipped scala-2.7.2.latest.zip to a
new directory and then in IDEA went to the Scala facet of my project and
created a new Scala SDK for that new directory. Simple as that.

The "latest" file is just a link to whatever the last nightly build was.

0
Comment actions Permalink

Thank you Steve! It works!
So, that internal error was caused by some error in 2.7.2 RC1, which is already fixed in a latest nightly build.

0

Please sign in to leave a comment.