0

Apologies as this is a newby question. I have the following SBT project containing a scala object. When I run 'Hi' I get "Class not found" exception. Where to specify the class path?

click here to see the screen shot

2 Answers 2

1

You need to delete this object and create a new one. Right click on src->main->scala(NOT in target folder) folder new -> Scala class -> type "Hi" in name field in check box choose object. And paste your:

def main(args: Array[String]) = println("hi") 
4
  • I don't see "Scala Class", only "Scala Worksheet" and "Scala Script" that's probably the problem, how to fix this?
    – ps0604
    Nov 13, 2015 at 20:44
  • Looks like you SBT didn't make a project yet. Open build.sbt and in top right corner you should have some blue popup with button like build or download dependencies. Or try Ctrl+Alt+Y
    – Yevgen
    Nov 13, 2015 at 20:48
  • It worked!! By the way, there are two directories scala and scala-211, when to use each? thanks
    – ps0604
    Nov 13, 2015 at 21:40
  • Both of them work, just put all your source files to one of them and when you will write unit test put them in corresponding folder test/scala or test/ scala-211
    – Yevgen
    Nov 14, 2015 at 10:28
0

This could be because main method doesn't have return type, try adding Unit so I must be like this:

def main(args:Array[String]):Unit = println("hi")

regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.