Reputation: 7691
So I have tried to import a library to Scala which comes as a Jar.
I have been looking for solutions online for half the day today, and at least got to the stage where I can successfully add the jar to the class path.
But when I try to import it now, it doesn't seem to work. I get an error: not found. I am working in an anaconda environment and I would like to load the package without using sbt.
This is the code I run:
scala> :require tinyir.jar
which returns
Added '/my/directory/structure/tinyir.jar' to classpath.
Then I run:
scala> import tinyir._
and I receive:
<console>:11: error: not found: value tinyir
import tinyir._
^
Many thanks for any comments. Any help much appreciated.
Upvotes: 0
Views: 914
Reputation: 2242
:require tinyir is enough
I'm assuming you are doing a scala course and trying to use http://www.da.inf.ethz.ch/files/tinyir.jar jar,
remember that Scala uses packages,
lnramirez:Downloads lnramirez$ ls -ltrh
-rw-r--r--@ 1 lnramirez 1240321454 42K Oct 19 15:43 tinyir.jar
lnramirez:Downloads lnramirez$ scala
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_65).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :require tinyir.jar
Added '/Users/lnramirez/Downloads/tinyir.jar' to classpath.
scala> import ch.ethz.dal.tinyir._
import ch.ethz.dal.tinyir._
scala>
Upvotes: 1