Adding .jar's to classpath (Scala)

You need to pass both classpath paths as a single argument.

Try this:

$ scalac -classpath "*.jar:dependencies/*.jar" PageRank.scala
$ scala -classpath "*.jar:dependencies/*.jar" PageRank
PageRankVertex(id=2, state=0.9999999999999997)
PageRankVertex(id=1, state=0.9999999999999997)

It worked for me.


It seems that depending on an installed version of Java, wildcards in classpath to include multiple JARs might or might not work. I found this trick elsewhere on StackOverflow (note that you can have as many folders after the 'echo' as you wish, separated by spaces):

scalac -classpath $(echo *.jar dependencies/*.jar | tr ' ' ':')  PageRank.scala
scala -classpath $(echo *.jar dependencies/*.jar | tr ' ' ':')  PageRank