Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can compile Scala programs but can't run them

I am able to compile scala programs using scalac in terminal but I get the warning.

Charless-Macintosh:src Charles$ scalac hello.scala
Charless-Macintosh:src Charles$ scala HelloWorld
No such file or class on classpath: HelloWorld

Is this to do with .profile on scala. I'm pretty confused as to what is happening. Many thanks

like image 965
Mark Avatar asked Jan 17 '15 11:01

Mark


1 Answers

The current directory is typically not in the classpath by default. So you need to give explicitly:

$ scala -cp . HelloWorld
like image 107
sjrd Avatar answered Oct 03 '22 00:10

sjrd