9 Feb 18:12
Scala sometimes fails to load a jar
Hello all,
I've been using scala fairly heavily and often just write short one
object programs that tie together a number of classes defined in a
java package i've been working with, as if my scala code is the main
for the java tools. I tend to run things without compiling with
simple commands like:
scala -cp sspace-lib.jar MyScalaProg.scala args_here
And that works for the most part, except on certain occasions where
scala, for reasons unknown, fails to load the associated jar, sspace-
lib.jar. Sometimes I can solve this by running scala from where the
jar is located, othertimes it's the exact opposite. Here's some
sample runs to clarify:
$ scala -cp bin/sspace-lib.jar DTest.scala
/home/stevens/devel/S-Space/DTest.scala:32: error: not found:
value log
a.zip(b).map(v=>if (v._1 == 0d) 0.0 else v._1 * log(v._1/
(v._2+eps))).sum
Everything looks as expected, I forgot to import log but otherwise it
recognizes my java based imports
$ cd bin
$ scala -cp sspace-lib.jar ../DTest.scala
/home/stevens/devel/S-Space/bin/../DTest.scala:1: error: not found:
object edu
import edu.ucla.sspace.vector.CompactSparseVector
^
/home/stevens/devel/S-Space/bin/../DTest.scala:2: error: not found:
object edu
import edu.ucla.sspace.common.Similarity
^
/home/stevens/devel/S-Space/bin/../DTest.scala:32: error: not found:
value log
a.zip(b).map(v=>if (v._1 == 0d) 0.0 else v._1 * log(v._1/
(v._2+eps))).sum
^
three errors found
Everything is not fine, my two imports using the sspace-lib.jar are
not recognized when I try to run scala from the jar's local
directory.
If i try to compile, things seem to work as normal, and I can
similarly load the jar into the interpreter from any directory. It
just seems to be that this particular use case *sometimes* doesn't
work. It's very finicky.
I can't really imagine why or how scala would fail to load up a jar
based on the current running directory. Has anyone else run into
similar problems? I've had this occur on two separate Redhat linux
machines and a Ubuntu laptop. All systems are running Java 6 with a
fairly recent sun jvm. I'm also using Scala version 2.9.1.final.
RSS Feed