# Sketch works in p3 but not p4

**URL:** <https://discourse.processing.org/t/sketch-works-in-p3-but-not-p4/35060>\
**Category:** Processing.py\
**Created:** [February 9, 2022, 4:37am UTC](https://discourse.processing.org/t/sketch-works-in-p3-but-not-p4/35060 "2022-02-09T04:37:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![degendev](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@degendev](https://discourse.processing.org/u/degendev)\
**Post date:** [February 9, 2022, 4:37am UTC](https://discourse.processing.org/t/sketch-works-in-p3-but-not-p4/35060/1 "2022-02-09T04:37:40Z")

</div>

> I had a sketch a wrote in processing.py (3 (the non blue logo version)) that ran on my older 2017 mbp  
> I also have a 2021 mbp (m1) with processing.py (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 java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader 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$1. **call** (Unknown Source)  
> at org.python.core.PyObject. **call** (PyObject.java:480)  
> at org.python.core.PyObject. **call** (PyObject.java:484)  
> at org.python.pycode.\_pyx17.f$0(Etheracts1.pyde:1)  
> at org.python.pycode.\_pyx17.call\_function(Etheracts1.pyde)  
> at org.python.core.PyTableCode.call(PyTableCode.java:171)  
> at org.python.core.PyCode.call(PyCode.java:18)  
> at org.python.core.Py.runCode(Py.java:1614)  
> at org.python.core.Py.exec(Py.java:1658)  
> 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.PyTableCode.call(PyTableCode.java:171)  
> at org.python.core.PyCode.call(PyCode.java:18)  
> at org.python.core.Py.runCode(Py.java:1614)  
> at org.python.core.Py.exec(Py.java:1658)  
> at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)  
> at jycessing.PAppletJythonDriver.processSketch(Unknown Source)  
> at jycessing.PAppletJythonDriver.findSketchMethods(Unknown Source)  
> at jycessing.Runner.runSketchBlocking(Unknown Source)  
> at jycessing.mode.run.SketchRunner.lambda$startSketch$3(Unknown Source)  
> at java.base/java.lang.Thread.run(Thread.java:829)”

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

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [February 9, 2022, 6:58am UTC](https://discourse.processing.org/t/sketch-works-in-p3-but-not-p4/35060/2 "2022-02-09T06:58:43Z")

</div>

Welcome @degendev

Is it possible to share the sketch code?

---

<div class="post-metadata">

**Author:** ![vdurnev](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@vdurnev](https://discourse.processing.org/u/vdurnev)\
**Post date:** [May 31, 2022, 8:56am UTC](https://discourse.processing.org/t/sketch-works-in-p3-but-not-p4/35060/3 "2022-05-31T08:56:06Z")

</div>

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](https://stackoverflow.com/questions/46694600/java-9-compatability-issue-with-classloader-getsystemclassloader)

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

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [May 31, 2022, 9:09am UTC](https://discourse.processing.org/t/sketch-works-in-p3-but-not-p4/35060/4 "2022-05-31T09:09:22Z")

</div>

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