I have tried to find a solution to my issue, but couldn’t. I am using Processing 4 with Python Mode.
I am trying to save the current frame as SVG and exit by pressing the “s” key. However, I am getting the following error:
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(LibraryImporter.java:315)
at jycessing.LibraryImporter.recursivelyAddJarsToClasspath(LibraryImporter.java:164)
at jycessing.LibraryImporter.addLibrary(LibraryImporter.java:140)
at jycessing.LibraryImporter$1.__call__(LibraryImporter.java:82)
at org.python.core.PyObject.__call__(PyObject.java:480)
at org.python.core.PyObject.__call__(PyObject.java:484)
at org.python.pycode._pyx38.f$0(sketch_220501a.pyde:1)
at org.python.pycode._pyx38.call_function(sketch_220501a.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._pyx37.f$0(C:/Users/user/AppData/Local/Temp/sketch_220501a16544851592084895088/sketch_220501a.pyde:96)
at org.python.pycode._pyx37.call_function(C:/Users/user/AppData/Local/Temp/sketch_220501a16544851592084895088/sketch_220501a.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(PAppletJythonDriver.java:233)
at jycessing.PAppletJythonDriver.findSketchMethods(PAppletJythonDriver.java:613)
at jycessing.Runner.runSketchBlocking(Runner.java:399)
at jycessing.mode.run.SketchRunner.lambda$2(SketchRunner.java:112)
at java.base/java.lang.Thread.run(Thread.java:833)
Here is my full code:
add_library("svg")
save_frame = False
total_degrees = 360
radius = 0
center_x = 0
center_y = 0
frames = 0
def setup():
global radius, center_x, center_y, svg_output
size(1600, 1000)
background(255)
stroke(0)
strokeWeight(1)
noFill()
svg_output = createGraphics(width, height, SVG, "file_01.svg")
radius = height * 0.6
center_x = width * 0.25
center_y = height / 2
def draw():
global total_degrees, radius, center_x, center_y, frames
if save_frame:
beginRecord(svg_output)
translate(frames * 3, 0)
beginShape()
for i in range(total_degrees):
noiseFactor = noise(i * 0.0130, float(frameCount) * 0.0115)
x = center_x + radius * cos(radians(i)) * noiseFactor
y = center_y + radius * sin(radians(i)) * noiseFactor
curveVertex(x, y)
endShape(CLOSE)
frames += 1
radius -= 2
if radius < 20:
noLoop()
if save_frame:
endRecord()
exit()
def keyPressed():
global save_frame
if key == "s":
save_frame = True
I found this solution on the forum and tried to implement, but can’t debug the issue. Any advice is appreciated!
Edit: deleted parts of the code that were not relevant to the issue