简体   繁体   中英

Scala REPL additional Jars

I am adding jars into my scala repl like so:

scala> :cp scalaj-http_2.10-2.2.1.jar
Added '/home/XXX/scalaj-http_2.10-2.2.1.jar'.  Your new classpath is:
".:/home/XXX/json4s-native_2.10-3.3.0.RC3.jar:/home/XXX/scalaj-http_2.10-2.2.1.jar"
Nothing to replay.

Now when I try and import that jar for use I get an error:

scala> import scalaj.http._
<console>:7: error: not found: value scalaj
       import scalaj.http._

I've tried this on another jar:

scala> :cp json4s-native_2.10-3.3.0.RC3.jar
Added '/home/XXX/json4s-native_2.10-3.3.0.RC3.jar'.  Your new classpath is:
".:/home/XXX/json4s-native_2.10-3.3.0.RC3.jar"
Nothing to replay.

scala> import org.json4s.JsonDSL._
<console>:7: error: object json4s is not a member of package org
       import org.json4s.JsonDSL._

I've read multuple tutorials online that all do it this way but my REPL does not seem to be behaving in the same manor. I am using Scala 2.10

Double check your path, if it still is not working you can try adding the jar at the time you start the REPL (it's always seemed to work for me, even with v2.10)

scala -cp /home/XXX/json4s-native_2.10-3.3.0.RC3.jar:/home/XXX/scalaj-http_2.10-2.2.1.jar

Note: That the delimeter between jars is ; for Windows and : otherwise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM