It turns out that this has nothing to do with Java. It seems that scripts in Scala 2.8 cannot find compiled classes in the same directory, even though the interactive mode can.
Two files: M1.scala and M2.scala as follows:
object M1 {
def test(a : Int) {
println("Testing " + a)
}
}
and
M1.test(13)
I compile M1 using scalac M1.scala, resulting in M1.class and M1$.class in the current directory.
Running scala M2.scala results in this:
$ scala M2.scala
M2.scala:2: error: not found: value M1
M1.test(13)
However, this works:
$ scala
Welcome to Scala version 2.8.1.final (OpenJDK Server VM, Java 1.6.0_20).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :load M2.scala
Loading M2.scala...
Testing 13
What also works is to replace the script M2.scala by a compiled scala class like this:
object M3 {
def main(args: Array[String]) {
M1.test(13)
}
}
Is this simply a bug?