Does Processing support packages?

I’m creating a physics simulator, and I want the “force” classes to be arranged in a class called force. I noticed Processing still has public private and package. However, I suspect these are from Java itself, and are not implemented in Processing .pde files. But I remain hopeful.

Does Processing actually support package?

1 Like

No, I don’t think the Processing editor supports packages in the way you’re describing.

You could use Processing as a Java library:

And then you could use packages. You could even export your code as a library and import that library back into the Processing editor if you wanted to.

1 Like
  • We can mix “.pde” w/ “.java” files together in the same sketch project folder. :coffee:
  • We can optionally use keyword package inside “.java” files. :package:
  • And then optionally use keyword import inside “.pde” files in order to access classes and interfaces inside those “.java” files. :open_file_folder:
  • Take a look at these 2 sketch links containing both “.pde” & “.java” files on them: :smile_cat:

1 Like

@GoToLoop How are you creating those .java files? When I try adding a package statement inside a .java tab in the Processing editor, I get an error.

It’s relatively recent that PDE allows keyword package inside “.java” files.
I’ve forgotten the exact version it was though.
However, even “.java” files can’t use any new Java 8 features yet.

Hi! I’m working on a project in which I want to incorporate some Java code. Since I’ve never done this before, I googled for examples and found yours. So I copy/pasted your code, but when I tried to run it, I got the following error:

No library found for gotoloop.countdown
The import gotoloop.countdown.Countdown conflicts with a type defined in the same file

I’m running Processing v3.5.4 under Windows 7, sp1. I wasn’t sure whether you needed to compile the Java code outside of Processing first, or whether Processing would take care of that for you, so I tried it both ways, with the same result. I compiled the Java code under Java v14.0.1.

Any idea what I’m doing wrong?


That’ll surely fail b/c P3 can’t use anything compiled after Java 8!

We’re gonna have to await for the P4 version.

'Til then you’re gonna need to pass some commands to Java 14 so it outputs Java 8 compiled code.

P.S.: We don’t need to compile “.java” files & package them as “.jar” files before using them on the PDE.

Make sure you don’t have any class or interface named Countdown somewhere else besides “” file.

Make sure you don’t have any “.pde” file named “Countdown.pde”.

Thanks. I finally got it to work after I removed the “import” statement from the Processing file and the “package” statement from the Java file.

That’s strange… Ru sure the Java file is actually using the extension “.java”: :question:

Glad your workaround worked as well. But it’s probably b/c the class Countdown is inside a “.pde” file instead of a “.java” 1. :coffee:

No, the Java file was named “” and the Processing file was named “JavaExample.pde”.

Just to make sure, I’ve copied & pasted the contents of the file “CountdownClass.pde” onto the main tab of the PDE.

Then created a “New Tab” (CTRL + SHIFT + N) typing in this exact name on the popup.

Again copied & pasted the contents of the file “” on that new Java tab.

Hit “Run” (CTRL + R) and they compiled & run on the PDE.

64-bit PDE v3.5.4 on Win 8.1 AMD laptop here.

I tried it again, following your steps exactly, and this time it ran, although I still see an error message in red in the console:

No library found for gotoloop.countdown
323 7823 7500 	 Delay: 7500  -  Done: false

If I remove the import statement, I get this error and the sketch doesn’t run.

Cannot find a class or type named “Countdown”

And finally, if I also remove the package statement, it runs without any error.

Maybe there’s something different in my setup, but I don’t know what. I’m running Processing 3.5.4 (64-bit) on Windows 7. But I don’t think that would make any difference.

This is some weird glitch on the PDE. Seems like it doesn’t like package declarations. :woozy_face: