2

I'm trying to run a scala file with Eclipse Indigo. I have installed the Scala IDE for Eclipse and am on the Scala perspective, but the option to run as a Scala application does not appear. The file that I am currently trying to run is part of an existing project that I imported into Eclipse. The Scala IDE plugin appears to be working as I can create Scala objects and run them as Scala Applications and the Scala compiler is detecting errors.

How do I get the option to run a file as a Scala Application for the Scala IDE plugin for Eclipse Indigo?

1
  • You need to copy-paste some code. As people have noted, it should work. There's nothing else you need to do, as long as the project builds without errors, and the main signature is correct (and inside an object). Commented Jan 28, 2013 at 20:40

1 Answer 1

2

The file you are trying to run must either be defined like this:

object MyFile extends App { /* your code to run here */ }

or:

object MyFile {
  def main(args: Array[String]) { /* your code to run here */ }
}

If either of these are true, you should be able to press the play button, via right click or the toolbar at the top.

Sign up to request clarification or add additional context in comments.

3 Comments

the signature of the main method must be def main(args: Array[String]) rather than def main(args: List[String])
@Faiz Good catch on the block comments.
The signature of the method is defined as main(args: Array[String]) but Eclipse cannot recognize a main method for the object.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.