This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Error in Eclipse :"Editor does not contain a main type"

8 replies
Jochen Herrmann
Joined: 2010-07-11,
User offline. Last seen 42 years 45 weeks ago.
Hi all,

I'm a newbie in Scala and had in the past not a lot with the C-world to do so maybe I simply have overseen something,
 but the below code compiles in Eclipse 3.5.2 (Scala IDE updated today)  with an error: "Editor does not contain a main type"
and I have no idea whats wrong .

package RationalPack

object MyMain {
    def main(args:Array[String]){
        val x=new Rational(49,13)
        val y=new Rational(47,128)
       
        println (x + "+" + y +"=" + x.+(y) )
        println (x + "*" + y +"=" + x*y )
    }
}

 Any idea's / hints ?

TIA
Joe Herrmann
Jesper
Joined: 2010-06-13,
User offline. Last seen 2 years 17 weeks ago.
Re: Error in Eclipse :"Editor does not contain a main type"
Hello Jochen,
That error is not a compiler error, but an error from Eclipse itself; it means that Eclipse doesn't see that your program has an entry point (the main method).
Your program looks OK, you've declared the main method with the correct signature, inside an object. It might be a bug in the IDE. I'm not using Eclipse for Scala myself, so I can't tell you in more detail what to do about it (I use NetBeans and the Scala plug-in that's available for it).
Jesper

2010/8/26 Jochen Herrmann <johe [dot] infotech [at] gmail [dot] com>
Hi all,

I'm a newbie in Scala and had in the past not a lot with the C-world to do so maybe I simply have overseen something,
 but the below code compiles in Eclipse 3.5.2 (Scala IDE updated today)  with an error: "Editor does not contain a main type"
and I have no idea whats wrong .

package RationalPack

object MyMain {
    def main(args:Array[String]){
        val x=new Rational(49,13)
        val y=new Rational(47,128)
       
        println (x + "+" + y +"=" + x.+(y) )
        println (x + "*" + y +"=" + x*y )
    }
}

 Any idea's / hints ?

TIA
Joe Herrmann



--
Jesper de Jong
jespdj [at] gmail [dot] com
Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Error in Eclipse :"Editor does not contain a main type"
That error only comes up when you click the default Run action. I think it's a bug in the Scala IDE, but in any case the solution is to create a run configuration and use it.

On Thu, Aug 26, 2010 at 10:34 AM, Jochen Herrmann <johe [dot] infotech [at] gmail [dot] com> wrote:
Hi all,

I'm a newbie in Scala and had in the past not a lot with the C-world to do so maybe I simply have overseen something,
 but the below code compiles in Eclipse 3.5.2 (Scala IDE updated today)  with an error: "Editor does not contain a main type"
and I have no idea whats wrong .

package RationalPack

object MyMain {
    def main(args:Array[String]){
        val x=new Rational(49,13)
        val y=new Rational(47,128)
       
        println (x + "+" + y +"=" + x.+(y) )
        println (x + "*" + y +"=" + x*y )
    }
}

 Any idea's / hints ?

TIA
Joe Herrmann

Zéide Peace
Joined: 2010-08-27,
User offline. Last seen 42 years 45 weeks ago.
Re: Error in Eclipse :"Editor does not contain a main type"
I've met with same problem.
And now, I use IntelliJ IDEA.

2010/8/26 Jochen Herrmann <johe [dot] infotech [at] gmail [dot] com>
Hi all,

I'm a newbie in Scala and had in the past not a lot with the C-world to do so maybe I simply have overseen something,
 but the below code compiles in Eclipse 3.5.2 (Scala IDE updated today)  with an error: "Editor does not contain a main type"
and I have no idea whats wrong .

package RationalPack

object MyMain {
    def main(args:Array[String]){
        val x=new Rational(49,13)
        val y=new Rational(47,128)
       
        println (x + "+" + y +"=" + x.+(y) )
        println (x + "*" + y +"=" + x*y )
    }
}

 Any idea's / hints ?

TIA
Joe Herrmann



--
(≥ⓛㅅⓛ≤)
Ne perdez pas courage!
Ce n`est pas encore fini.
Jochen Herrmann
Joined: 2010-07-11,
User offline. Last seen 42 years 45 weeks ago.
Re: Error in Eclipse :"Editor does not contain a main type"
Thanks for your replies !

Have posted a ticket at scala-ide.org

Jesper, I think I will give Netbeans with Scala-Plugin a try. Is it less complicated than Eclipse !?

Naftoli, sorry, I'm also new to Eclipse: How can I define a "run configuratrion" in Eclipse and why do you assume that it would work ? A link or hint would be great.

Zéide, I'm still learning and have not yet decided, whether I will use it for my job or not. So I don't see the necessity to invest already money in an IDE. I was told that Eclipse would be a professional IDE and bugs can happen, especially if new software.

Joe Herrmann


milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Error in Eclipse :"Editor does not contain a main type"

On Fri, Aug 27, 2010 at 8:40 AM, Jochen Herrmann
wrote:
> Thanks for your replies !
>
> Have posted a ticket at scala-ide.org

Thanks ... from the looks of it it's an easily fixable configuration issue.

The best place for this discussion is the Scala IDE user list,

http://groups.google.com/group/scala-ide-user

Cheers,

Miles

Guofeng Zhang
Joined: 2010-08-17,
User offline. Last seen 42 years 45 weeks ago.
RE: Error in Eclipse:"Editor does not contain a main type"

I use Scala IDE, M2Eclipse and m2eclipse-scala, and  use Run or Run As to launch any Scala code without meeting the problem.

 

From: Zéide Peace [mailto:zeide0325 [at] gmail [dot] com]
Sent: Friday, August 27, 2010 12:46 PM
To: Jochen Herrmann
Cc: scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Error in Eclipse:"Editor does not contain a main type"

 

I've met with same problem.
And now, I use IntelliJ IDEA.

2010/8/26 Jochen Herrmann <johe [dot] infotech [at] gmail [dot] com>

Hi all,

I'm a newbie in Scala and had in the past not a lot with the C-world to do so maybe I simply have overseen something,
 but the below code compiles in Eclipse 3.5.2 (Scala IDE updated today)  with an error: "Editor does not contain a main type"
and I have no idea whats wrong .

package RationalPack

object MyMain {
    def main(args:Array[String]){
        val x=new Rational(49,13)
        val y=new Rational(47,128)
       
        println (x + "+" + y +"=" + x.+(y) )
        println (x + "*" + y +"=" + x*y )
    }
}


 Any idea's / hints ?

TIA
Joe Herrmann




Jesper
Joined: 2010-06-13,
User offline. Last seen 2 years 17 weeks ago.
Re: Error in Eclipse :"Editor does not contain a main type"
You can get NetBeans from http://netbeans.org/
You can get the Scala plug-in for NetBeans from http://sourceforge.net/projects/erlybird/files/nb-scala/6.9v1.1.0/
Installation instructions for the plug-in here: http://wiki.netbeans.org/Scala68v1(those are for NetBeans 6.8, but for 6.9 it's the same).
I can't tell you if it's more or less complicated than Eclipse. The NetBeans plug-in does have some bugs, but at the moment there isn't a Scala IDE which is bugfree and has just as much functionality as is available for Java.
Besides Eclipse and NetBeans there is IntelliJ IDEA, which apparently has a good Scala plug-in: http://www.jetbrains.com/idea/(the Community Edition is free).
Jesper
2010/8/27 Jochen Herrmann <johe [dot] infotech [at] gmail [dot] com>
Thanks for your replies !

Have posted a ticket at scala-ide.org

Jesper, I think I will give Netbeans with Scala-Plugin a try. Is it less complicated than Eclipse !?

Naftoli, sorry, I'm also new to Eclipse: How can I define a "run configuratrion" in Eclipse and why do you assume that it would work ? A link or hint would be great.

Zéide, I'm still learning and have not yet decided, whether I will use it for my job or not. So I don't see the necessity to invest already money in an IDE. I was told that Eclipse would be a professional IDE and bugs can happen, especially if new software.

Joe Herrmann





--
Jesper de Jong
jespdj [at] gmail [dot] com
Razvan Cojocaru 3
Joined: 2010-07-28,
User offline. Last seen 42 years 45 weeks ago.
Re: Error in Eclipse :"Editor does not contain a main type"

In the run menu, click on the "run configurations" at the bottom and
will see the list of all programs you've run so far - just create a
new one and manually type in the class name.

On 8/27/10, Jochen Herrmann wrote:
> Thanks for your replies !
>
> Have posted a ticket at scala-ide.org
>
> Jesper, I think I will give Netbeans with Scala-Plugin a try. Is it less
> complicated than Eclipse !?
>
> Naftoli, sorry, I'm also new to Eclipse: How can I define a "run
> configuratrion" in Eclipse and why do you assume that it would work ? A link
> or hint would be great.
>
> Zéide, I'm still learning and have not yet decided, whether I will use it
> for my job or not. So I don't see the necessity to invest already money in
> an IDE. I was told that Eclipse would be a professional IDE and bugs can
> happen, especially if new software.
>
> Joe Herrmann
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland