How to fire up Scala interpreter with ScalaCheck in the classpath in Ubuntu 11.10?

355 Views Asked by At

Scala is installed and working fine.
scalacheck.jar is placed in the /bin .
I used the following command

$ scala -cp scalacheck.jar

After that, when i tried the below command,

scala> import org.scalacheck.Prop.forAll

I got the following error.

<console>:7: error: object scalacheck is not a member of package org
   import org.scalacheck.Properties
              ^

I might have done some mistake in using scalacheck, please correct me and give the proper commands so that I can able to work with scalacheck in Ubuntu in interpreter mode.

2

There are 2 best solutions below

1
On BEST ANSWER

Putting executable on the path isn't the same as jar being on the classpath, so your jar being in /bin didn't change anything.

Just use:

scala -cp path_to_your.jar 

and you should be fine.

If for example, your scalachek.jar is in /bin then use:

scala -cp /bin/scalacheck.jar

edit:

Putting jars in /bin probably isn't the best idea.

0
On

You can use it like this:

kjozsa@walrus:~$ scala -version
Scala code runner version 2.9.2 -- Copyright 2002-2011, LAMP/EPFL
kjozsa@walrus:~$ locate scalacheck.jar
/usr/share/scala/lib/scalacheck.jar
kjozsa@walrus:~$ scala -cp /usr/share/scala/lib/scalacheck.jar
Welcome to Scala version 2.9.2 (OpenJDK 64-Bit Server VM, Java 1.7.0_03-icedtea).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import org.scalacheck.Prop.forAll
import org.scalacheck.Prop.forAll

scala>