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 publicprivate and package. However, I suspect these are from Java itself, and are not implemented in Processing .pde files. But I remain hopeful.
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.
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.
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.