Sketch works in p3 but not p4

I had a sketch a wrote in (3 (the non blue logo version)) that ran on my older 2017 mbp
I also have a 2021 mbp (m1) with (4 (the blue one)) running on it.
For some reason my sketch file only runs on the older processing version (on my older machine)
When I try to run it on the newer machine/software I get tons of errors about

“ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class (jdk.internal.loader.ClassLoaders$AppClassLoader and are in module java.base of loader ‘bootstrap’)
at jycessing.LibraryImporter.addJarToClassLoader(Unknown Source)
at jycessing.LibraryImporter.recursivelyAddJarsToClasspath(Unknown Source)
at jycessing.LibraryImporter.addLibrary(Unknown Source)
at jycessing.LibraryImporter$ Source)
at org.python.pycode._pyx17.f$0(Etheracts1.pyde:1)
at org.python.pycode._pyx17.call_function(Etheracts1.pyde)
at org.python.core.Py.runCode(
at org.python.core.Py.exec(
at org.python.pycode._pyx16.f$0(/Volumes/TheShed/Etheracts1/Etheracts1.pyde:96)
at org.python.pycode._pyx16.call_function(/Volumes/TheShed/Etheracts1/Etheracts1.pyde)
at org.python.core.Py.runCode(
at org.python.core.Py.exec(
at org.python.util.PythonInterpreter.exec(
at jycessing.PAppletJythonDriver.processSketch(Unknown Source)
at jycessing.PAppletJythonDriver.findSketchMethods(Unknown Source)
at jycessing.Runner.runSketchBlocking(Unknown Source)
at$startSketch$3(Unknown Source)
at java.base/”

Is this a problem with my newer machine? Or with the different versions of the software?

Welcome @degendev

Is it possible to share the sketch code?

Hi @tabreturn

I see this error when I try to load any library with add_library statement.
And looks like it appears in Processing 4 due to the switch to Java 17.
In the stackoverflow there are many questions regarding similar problems after switching to Java 9 and higher
See for example Java 9, compatability issue with ClassLoader.getSystemClassLoader - Stack Overflow

In my Processin 4.0b8 with Python mode 4001 under Windows 10 and with OpenJdk 17.0.2 next script generates such error:
def setup():
snd = SoundFile(this,“sound.mp3”)

I recommend you use Processing 3.5.4 for Python Mode. At least until Processing 4 is out of beta.

1 Like