Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can I use a Java lib from the Scala REPL but not from a script?
    primarykey
    data
    text
    <p>I’m working on a Scala script which uses Joda Time. Up until today, this was working fine. Somehow, something’s changed and it’s no longer working.</p> <p>This works:</p> <pre><code>$ scala -cp "lib/*" Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29). Type in expressions to have them evaluated. Type :help for more information. scala&gt; import org.joda.time._ import org.joda.time._ scala&gt; Period.minutes(5) res0: org.joda.time.Period = PT5M </code></pre> <p>but this doesn’t:</p> <pre><code>$ scala -cp "lib/*" test.scala /Users/avi/Dev/experiments/rollups/scala/test.scala:4: error: object joda is not a member of package org import org.joda.time._ ^ one error found </code></pre> <p><code>test.scala</code> contains only:</p> <pre><code>#!/usr/bin/env scala -cp lib/* -deprecation !# import org.joda.time._ Period.minutes(5) </code></pre> <p>this also doesn’t work:</p> <pre><code>$ scala -cp "lib/*" -e "import org.joda.time._" /var/folders/c4/gh5y9_cx5bz8x_4wm060l_mm0000gn/T/scalacmd1248995773392653303.scala:1: error: object joda is not a member of package org import org.joda.time._ ^ one error found </code></pre> <p>It’s also not caused by using <code>*</code> in the <code>cp</code> arg:</p> <pre><code>$ scala -cp lib/joda-time-2.0.jar:lib/joda-convert-1.2.jar -e "import org.joda.time._" /var/folders/c4/gh5y9_cx5bz8x_4wm060l_mm0000gn/T/scalacmd5438658792813459030.scala:1: error: object joda is not a member of package org import org.joda.time._ ^ one error found </code></pre> <p>…It’s just so crazy because this was working last time I worked on this project, just a day or two ago! And now it’s not working, and I guess I must have changed something, but honestly I can’t think of what it might be.</p> <p>Help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload