Importing a "Java Processing" library into py5

Thank you everyone for your responses here! I’m really excited to see the community coming together to answer this.

One thing I’ll add is that you don’t need import jpype.imports is because import py5 takes care of that for you. Early versions of py5 did not, but this has been in py5 for a while now.

Putting the jars in a “jars” subdirectory is the easiest way to add Jars to a Sketch. Jars must be added to the Java Virtual Machine (JVM) before the JVM is started, which happens when import py5 is called. For folks using py5 in imported mode via Thonny, you can’t use py5_tools to add the Jars because the JVM will always be already running by that time. Instead, put the Jars in a “jars” subdirectory relative to the current working directory (os.getcwd()). py5 will always check for this before starting the JVM.

2 Likes