0

I'm trying to get Processing working under Scala and sbt and I'm running into a strange issue. Trying to run the following program (Main.scala):

import processing.core.PApplet

class ProcessingTest extends PApplet {

  override def setup() {
    size(1024, 768)
    background(10)
  }

  override def draw() {

  }
}

object ProcessingTest extends App {
  PApplet.main("ProcessingTest")
}

results in a runtime exception:

[error] (Animation Thread) java.lang.NoClassDefFoundError: processing/data/StringList
[error] java.lang.NoClassDefFoundError: processing/data/StringList
[error]     at processing.core.PApplet.insideSettings(PApplet.java:915)
[error]     at processing.core.PApplet.size(PApplet.java:1987)
...

Strangely, however, I am able to create a processing.data.StringList in an sbt console session:

scala> new processing.data.StringList("foo","bar")
res1: processing.data.StringList = StringList size=2 [ "foo", "bar" ]

Why could this be happening? Possible relevant details: I'm using Oracle Java 8, and my sbt dependencies are setup as follows:

val ProcessingVersion = "3.3.7"
libraryDependencies ++= {
  Seq(
    "org.processing" % "core" % ProcessingVersion,
    "org.processing" % "net" % ProcessingVersion,
    "org.processing" % "serial" % ProcessingVersion,
    "org.processing" % "pde" % ProcessingVersion,
    "org.processing" % "pdf" % ProcessingVersion
  )
}
b4c3
  • 43
  • 1
  • 4
  • https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java – Dmytro Mitin Aug 10 '20 at 20:18
  • I'm aware of what causes a NoClassDef error. My specific question is why I don't see the error when conjuring the object in sbt console. My understanding is that `sbt console` uses a nearly identical runtime to `sbt run` – b4c3 Aug 10 '20 at 20:48
  • Did you do `sbt clean`? Also look at https://stackoverflow.com/questions/16551772/java-lang-noclassdeffounderror-when-using-console (it's reversed situation to yours, code runs in IDE but throws `NoClassDefFoundError` in console). – Dmytro Mitin Aug 10 '20 at 20:58

0 Answers0