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

0
16 comments
Avatar
Permanently deleted user

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

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
Avatar
Permanently deleted user

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

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

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

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

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

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

0

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

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

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

Ilya

0

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

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

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

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


It appears that you're encountering a compiler error in your Scala project, specifically related to the main method not being found. Given that your code appears correct and you've tried some troubleshooting steps, here are a few additional things you can check:

Project SDK: Ensure that you have the correct Scala SDK set for your project. In IntelliJ IDEA, go to File > Project Structure > Project, and verify that the Project SDK is set to the appropriate version of Scala.

Scala Facet: Double-check that the Scala facet is correctly set for your project. In Project Structure, under Modules, select your module, and make sure that Scala is listed under the Facets tab.

Invalid Configuration: Since you mentioned that you encountered the error after clicking "Edit Configuration," it's possible that there's an issue with your run configuration. Try deleting the existing run configuration for your project and create a new one. Right-click on your project in the Project Explorer, then select Run > Edit Configurations. Remove the existing configuration and create a new one with the correct main class specified.

Reimport Project: Sometimes, IntelliJ IDEA may not properly detect changes in the project configuration. Try reimporting your project by going to File > Invalidate Caches / Restart > Invalidate and Restart. After restarting, let IntelliJ IDEA rebuild the project.

IDE or Plugin Issues: As a last resort, it's possible that there could be an issue with the IntelliJ IDEA IDE or the Scala plugin. Ensure that you have the latest updates and bug fixes for both IntelliJ IDEA and the Scala plugin. If the issue persists, you might consider reporting it to JetBrains, the developers of IntelliJ IDEA, or the Scala plugin maintainers.

If none of these steps resolve the issue, omproductions might be worth checking the IntelliJ IDEA forums or Scala plugin-specific forums for similar issues and solutions, as it could be a bug or configuration problem specific to your environment.

 


 

0

Please sign in to leave a comment.