Under Windows, I can run a Scala script from a different directory using a batch script like:
Hello.bat:
@scala "%~dp0Hello.scala" %*
(%~dp0 will be translated to the path where the batch file is)
So I can call it like this:
c:\somedir>path\to\scala\script\Hello
Hello World!
c:\somedir>path\to\scala\script\Hello Moon
Hello Moon!
Or, if the directory where the script is is already in the path, I could simply use:
c:\somedir>Hello
Hello World!
c:\somedir>Hello Moon
Hello Moon!
I can't do the same thing for compiled classes:
@scala "%~dp0Hello.class" %*
won't work, and
@scala -howtorun:object "%~dp0Hello.class" %*
wont't work either, as well as
@scala -howtorun:object "%~dp0Hello" %*
This one:
@scala -howtorun:object "Hello" %*
only works if I am at the same directory, same as:
@scala Hello %*
And:
@cd %~dp0
@scala Hello %*
works, but it exits in the directory of the script, not where I was when I called it!
How can I tell scala where to find a class that I am trying to run?