vishvAs vAsuki vishvAs vAsuki - 3 months ago 14x
Bash Question

Running scala shell script : Nothing happens

If I run the below script (saved as, which is an executable file) in a command line, nothing happens:

# exec scala -classpath "/usr/local/google/home/vvasuki/sanskritnlpjava/target/sanskritnlp-1.0-SNAPSHOT.jar " "$0" "$@"
exec scala "$0" "$@"

# import sanskritnlp.transliteration._;
print "hello"

I just see no output. Nothing. Command prompt does not return either.

What is happening here? I have to type Ctrl+C to stop whatever is happening.

EDIT: Using scala 2.9 in ubuntu 14.04 :


Your pre-packaged version of Scala is from a long time ago and a galaxy far, far away.

You'll do better to download the latest 2.11.6 from the website.

When the scala runner runs a script, it starts a compile server process. If that process is borked, you may have to kill it or run fsc -shutdown to ask it nicely to go away.

You can try adding the -nc option to your script to eliminate that factor, i.e., scala -nc says no compile daemon.

Finally, if you're just testing your library, it's more common to run scala -cp my.jar and experiment from the REPL. Or if you are using SBT, start the console from there.

Anonymous suggests adding: "They seriously let you type anything on here"

To which I'll append the advice from the other answer, to run fsc -verbose. And note that they threaten to stop supporting fsc because it has issues which are maddening when they occur. For that reason, I prefer scala -nc for brief testing and scalac -d script.jar script.scala where script is an App.