When I paste a code fragment into the scala interpreter, it works as
expected, but when I attempt to run the same file using
scala ./name-of-file.scala
It prints
<my hostname>: <my hostname>
I am on Fedora 11, and the Scala version I am using is 2.7.7final.
Does running the following command works?
If it doesn’t, that’s most likely your problem.
You see, because not only Scala programs run on JVM, but the Scala compiler itself runs on JVM, and the JVM has pretty steep starting times, when running scripts Scala keeps a copy of the compiler running in background as a daemon, and talks to it through a TCP connection.
Alas, it gets the IP address by resolving the hostname, which means any computer which has a hostname that is not associated to a valid IP address on that hostname will have problems.