Shakti
Shakti

Reputation: 2033

There is "Run Configuration" but no "Run As Scala Application" in Eclipse

I have the following Scala class, I am able to run it from command line by first typing sbt then in sbt mode. But I am not able to run it from eclipse . I am already in scala perspective.

> run-main bcomposes.twitter.QuerySearch #IPL


package bcomposes.twitter

import twitter4j._
import collection.JavaConversions._

/**
 * Gets a Twitter instance set up and ready to use.
 */
trait TwitterInstance {
  val twitter = new TwitterFactory().getInstance
}

/**
 * Given a command line query, search for tweets and print
 * them.
 */
object QuerySearch extends TwitterInstance {

  def main(args: Array[String]) { 
    val statuses = twitter.search(new Query(args(0))).getTweets
    statuses.foreach(status => println(status.getText + "\n"))
  }

}

Upvotes: 3

Views: 10672

Answers (5)

Srikanth Chillapalli
Srikanth Chillapalli

Reputation: 61

Make sure the package name you specified under which your scala object file is added matches the package name you mentioned in your code. So, correct this and then check, "Run as Scala Application" should be available now

Upvotes: 6

Suresh Kumar Pathak
Suresh Kumar Pathak

Reputation: 315

"Run as Scala application" will show in Eclipse Scala IDE only if we extends the Scala object with 'APP' class.

Example:

package grreter
object Exp extends App{
  println("Hello, New World!")
}

(Note: if you comment "extends App" then 'Run As Scala Application' will not show.)

Upvotes: 0

Hatter  Bush
Hatter Bush

Reputation: 225

The way I solve this problem is using maven to compile and package the project , when the maven build is correct, the "run as scala application" appear again.

Upvotes: -1

tse
tse

Reputation: 6069

Try to click right button on the Scala object with main method (not on the root project element). Then the "Run as... Scala application" menu item appears.

Upvotes: 0

Eugene Ryzhikov
Eugene Ryzhikov

Reputation: 17359

Your Scala file has to be a part of Scala project. Create Scala project using Scala Project wizard, add your file to it and try again.

Upvotes: 1

Related Questions