Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot add a jar to scala repl with the :cp command

If I issue:

$ scala -classpath poi-3.9/poi-3.9-20121203.jar 

scala> import org.apache.poi.hssf.usermodel.HSSFSheet
import org.apache.poi.hssf.usermodel.HSSFSheet

Everything works ok, but if instead I issue:

$ scala

scala> :cp poi-3.9/poi-3.9-20121203.jar
Added '/home/sas/tmp/poi/poi-3.9/poi-3.9-20121203.jar'.  Your new classpath is:
".:/home/sas/tmp/poi/poi-3.9/poi-3.9-20121203.jar"
Nothing to replay.

scala> import org.apache.poi.hssf.usermodel.HSSFSheet
<console>:7: error: object apache is not a member of package org
       import org.apache.poi.hssf.usermodel.HSSFSheet
                  ^

Am I missing something?

like image 852
opensas Avatar asked Aug 03 '13 14:08

opensas


1 Answers

No one seems to mention this but the correct solution is using the :require command:

scala> :require foo.jar
Added 'foo.jar' to classpath.
like image 108
Jus12 Avatar answered Sep 19 '22 22:09

Jus12