score:0

i do not use eclipse, but have you tried this way?

object test extends app { println("hello world") }

score:0

your class isn't set as a class that can be launched.

you need to extend app and put the body of your code directly in the class, like this:

package asd

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

score:0

i just did a complete installation of eclipse and the scala ide for eclipse, created a runnable scala object using it and ran that object to produce the expected output with no problems. my installation platform is windows 7 x86_64. this is what i did:

  1. downloaded eclipse-jee-luna-sr2-win32-x86_64.zip from columbia university at the eclipse downloads - 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

  2. unbundled the download and updated its eclipse.ini file with -xms256m and -xmx2048m

  3. created a new workspace folder

  4. started eclipse by double clicking on eclipse.exe in the folder of the unbundled download and entered the pathname of the new workspace folder in its workspace launcher's select a workspace pop-up when it became available

  5. in the running eclipse selected help > install new software... to get the available software pop-up, clicked on add in it to get the add repository pop-up and in that added the url for the scala ide for eclipse4.4 (luna) for scala 2.11.6 provided at http://scala-ide.org/download/current.html (the ide repo url is http://download.scala-ide.org/sdk/lithium/e44/scala211/stable/site) giving it the name "scala ide for eclipse4.4 (luna) for scala 2.11.6" and clicked ok.

  6. in the resulting available software pop-up selected everything visible (scala ide for eclipse, scala ide for eclipse development support, scala ide for eclipse source feature, scala ide plugins (incubation) and sources), clicked on next and clicked on finish

  7. after the installation finished it was required to restart eclipse so i did that

  8. after the restart finished, in the running eclipse opened the scala perspecive by selecting window > open perspective > other > scala

  9. created a new scala project by selecting file > new > scala project, giving it the name "helloworld" and clicked on finish

  10. in the helloworld project right clicked on src and selected new > package, entered "tn" and clicked on finish

  11. right clicked on the tn package in helloword/src, selected new > scala object, gave it the name "helloworld" and clicked on finish

  12. in the editor window of the helloworld object that came up, added "extends app" to the object's definition and println("hello world") in its body. here are the contents of the helloworld.scala file:

    package tn
    
    object helloworld extends app {
      println("hello world")
    }
    
  13. ran the helloworld object by right clicking in its editor window and selecting run as > scala application which caused "hello world" to be printed in the console view

score:0

if your scala source has a main object like this:

package org.xx.yy

object mypackage extends app {
}

then in eclipse ide set "debug configurations->scala application->main class" to "org.xx.yy.mypackge"

score:3

though it is scala ide :) it still expects the class scala file to be found in the right package dir.

e.g. testobject.scala should be part of src/main/scala/asd

we too had to change the scala file location for our app main class to be able to debug it in scala ide. small nuisance.


Related Query

More Query from same tag