AtomicScala / atomic-scala-corrections

Find out about or report corrections for the book "Atomic Scala"
http://www.atomicscala.com
6 stars 2 forks source link

scala package import example problem p97 #36

Open dave-gil opened 8 years ago

dave-gil commented 8 years ago

Hi, I am having trouble with the following code on page 97 re importing a package

Run the script as usual with: scala ImportPythagorean.scala You need ‘.’ In your CLASSPATH for this to work. A bug in Scala 2.11 and below causes a delay between compiling and making the classes available for import. To get around this bug, use nocompdaemon: scala -nocompdaemon ImportPythagorean.scala

even when I attempt to run the script using the '-nocompdaemon' command it still fails giving error:

error: not found: value pythagorean import pythagorean.RightTriangle

the directory structure appears correct after compiling PythagoreanTheorem.scala showing a new dir with name pythagorean containing a single class RightTriangle.class

the info given, doesn't really explain how what you really need to add to your CLASSPATH or what to if the workaround fails? I've looked online but as a noob I can't fathom it! I am actually amazed that in v2.11 there are any bugs regarding making any compiled classes available? Anyway any help would be greatly appreciated.

Dave

dave-gil commented 8 years ago

FYI

scala -nocompdaemon -cp . ImportPythagorean.scala

works

jasonfilippou commented 8 years ago

What is your operating system? In a Linux environment, I'm wondering if adding

export CLASSPATH='path_to_atomic_scala_directory'$CLASSPATH

to your .bashrc would work (make sure you source the file afterwards). I'm not in a Linux environment right now so I can't test this.

dave-gil commented 8 years ago

no windows 7 pro 64-bit