Scala main class not found in Eclipse ide

I have installed scala and scala IDE for eclipse. I get this message every time I try to compile a simple "HelloWorld":

package asd

object testobject {
  def main(args: Array[String]): Unit = {
    println("asda");
  }
}

      

"Error: Mainclass asd.testobject not found"

New scala Project → asd

New scala Object -> Copy and paste the code above

Run as -> scala Application

My problem is that I've literally literally tried everything I've found on the internet and it won't work. I really don't know why this doesn't work. Main class in Runconfig: asd.testobject. I really hope some of you can help me, I think I haven't included environment or scala somewhere somewhere ... ??

scala version: 2.11.6

EDIT :: @dragonborn I don't quite understand what you mean? I took a snapshot that shows my configuration for scala. Can you explain this?

I can't post pictures here, so here is the link: scala config

+3


source to share


5 answers


Although this is a Scala IDE :), it still expects the Scala class file to be found in the correct dir.

eg. testobject.scala must be part of src / main / scala / asd



We also had to change the location of the Scala file for our main application so that it can be debugged in the Scala IDE. A small nuisance.

+1


source


I am not using eclipse, but have you tried this way?



object Test extends App { println("hello world") }

0


source


Your class is not defined as a runnable class.

You need to extend App

and place the body of your code directly into the class, for example:

package asd

object testobject extends App {
    println("asda");
}

      

0


source


I just did a full install of Eclipse and Scala IDE for Eclipse, created it with a Scala runwable object, and ran that object to get the expected result without issue. My installation platform is Windows 7 x86_64. This is what I did:

  • downloaded eclipse-jee-luna-SR2-win32-x86_64.zip from Columbia University on Eclipse download - mirror selection page at https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/ release / luna / SR2 / eclipse-jee-luna-SR2-win32-x86_64.zip

  • split the download and updated the eclipse.ini file with -Xms256m and -Xmx2048m

  • created a new workspace folder

  • launched eclipse by double clicking on eclipse.exe in the split download folder and entering the path to the new workspace folder in my Launcher workspace. Select the workspace popup when available

  • in the current eclipse, choose Help> Install New Software ... to open the Available Software pop-up, click Add to get the Add Repository pop-up and it has added the URL for Scala IDE for Eclipse4.4 (Luna) For Scala 2.11.6 provided http://scala-ide.org/download/current.html (IDE repository URL http://download.scala-ide.org/sdk/lithium / e44 / scala211 / stable / site ) by giving it the name of the Scala IDE for Eclipse4.4 (Luna) for Scala 2.11.6 "and clicking OK.

  • all visible is selected in the Available Software popup that appears (Scala IDE for Eclipse, Scala IDE for Eclipse development support, Scala IDE for Eclipse source function, Scala IDE plugins (incubation) and Sources), click Next and click Finish

  • After the installation finished, it needed to restart Eclipse, so I did this

  • after the restart finishes in running eclipse, Scala perspecive will open by choosing Window> Open Perspective> Other> Scala

  • created a new Scala project by going to File> New> Scala Project, giving it the name HelloWorld and clicking Finish

  • in the HelloWorld project, right click on the src and choose New> Package, enter "tn" and click Finish

  • right click on the tn package in HelloWord / src, choose New> Scala Object, name it "HelloWorld" and click "Finish"

  • in the HelloWorld object editor window that appeared, added "extends application" to the object definition and println ("hello world") in its body. Here is the content of the HelloWorld.scala file:

    package tn
    
    object HelloWorld extends App {
      println("hello world")
    }
    
          

  • launched the HelloWorld object by right-clicking in its editor window and choosing Run As> Scala Application which caused "hello world" to be printed in the Console view

0


source


If your scala source has a main object like:

package org.xx.yy

object MyPackage extends App {
}

      

Then in Eclipse IDE set "Debug Configurations -> Scala Application -> Main Class" to "org.xx.yy.MyPackge"

0


source







All Articles