hello.scala script execution

267 views
Skip to first unread message

Maixent Assi

unread,
Aug 15, 2013, 6:12:45 PM8/15/13
to scala...@googlegroups.com
Hi all,
I am a new user to scala. And I have difficulties following the book 'Programming in scala 2nd edition'.
I am not able to execute the script 'hello.scala' created.

When i run the following script on my computer (a windows 7 powered machine), i get the following error. I don't understand. If I dont figure out this problem, i will be unable to continue with my discovery of scala.
scala> scala hello.scala
<console>:1: error: ';' e
       scala hello.scala

NB: the above 'hello.scala' script file has been created in  C:\Users\maixent\Documents\Scala.

Please help me! Thanks in advance

Vlad Patryshev

unread,
Aug 15, 2013, 6:32:20 PM8/15/13
to Maixent Assi, scala-user
Maixent,

It would make sense if you posted the content of the file, hello.scala.
This one should work:
object main {
  def main(args: Array[String]) = { println("hello there") }
}

Thanks,
-Vlad


--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Antoine Gourlay

unread,
Aug 15, 2013, 6:41:28 PM8/15/13
to Vlad Patryshev, Maixent Assi, scala-user

From your error it looks like you are trying to run the script from the scala REPL instead of running it directly, i.e. you are doing this:

$ scala
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.

scala> scala hello.scala
<console>:1: error: ';' expected but '.' found.
       scala hello.scala
                  ^

instead of directly this, directly in your console:

$ scala hello.scala

Maixent Assi

unread,
Aug 16, 2013, 5:18:35 AM8/16/13
to scala...@googlegroups.com, Vlad Patryshev, Maixent Assi
Thank you for your interest in helping me grow with Scala. The code in the "hello.scala" file is 'println('Hello, World!'), the basic start with scala scripting in Martin Odersky's Functional Programming with Scala 2nd Edition.

Maixent Assi

unread,
Aug 16, 2013, 7:39:55 AM8/16/13
to scala...@googlegroups.com, Vlad Patryshev, Maixent Assi
Antoine, thank you. Really. I exited from the ">scala" thing and got the"C:\Users\massi\" thing. i went to the directory where is located the file and it worked. "Now i know the distinction between REPL and console. Lol.


Le jeudi 15 août 2013 22:41:28 UTC, Antoine Gourlay a écrit :
Reply all
Reply to author
Forward
0 new messages