views:

138

answers:

2

I'm trying to replace a bunch of Linux shell scripts with Scala scripts.

One of the remaining challenges is how to scan an entire directory of JARs and place them into the classpath. Currently this is done in the shell script prior to invoking the scala JVM. I'd like to eliminate the shell script completely.

Is there an elegant scala idiom for this?

I have found this other question but in Java it seems hardly worthwhile to mess with it: http://stackoverflow.com/questions/252893/how-do-you-change-the-classpath-within-java

+3  A: 

The JVM itself supports a wild-card notation in the class-path. If /foo/bar is a directory holding JAR files, all of which you want to be in the class-path, you can include /foo/bar/* in the class-path instead of enumerating each JAR file individually.

I'm not sure that will suffice for your purposes, but it's handy when it's suitable.

Randall Schulz
But this is implemented only in JDK 1.6
We welcome you in the present.
Randall Schulz
A: 

Um, this is directly supported, you don't even need the java support. Did you try it?

scala -cp '/foo/bar/*'
extempore