Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I can't execute scala file?

Tags:

scala

I am a newbie to Scala, it's the first time I'm running Scala, when I installed Scala, I created a file named Hello.scala, the content is:

println("HelloWorld!")

when I typed scala, there was no problem, the scala REPL was shown, but when I typed scala Hello.scala, it prompted:

<console>:1: error: ';' expected but '.' is found.

I dont know what problem is, I hope someone can help me.

like image 814
user1653363 Avatar asked Sep 13 '12 04:09

user1653363


1 Answers

  • Adding -nc flag saved my day.

    scala -nc Hello.scala

  • What is -nc?

    -nc no compilation daemon: do not use the fsc offline compiler

    Source: http://alvinalexander.com/java/jwarehouse/scala-2.11/compiler/scala/tools/nsc/GenericRunnerCommand.scala.shtml

  • What is fsc offline compiler?

    fsc – Fast offline compiler for the Scala 2 language

    Source: http://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html

like image 88
Mingyu Avatar answered Sep 21 '22 13:09

Mingyu