[SOLVED] Importing other Processing classes

Hello, this question might seem very blatant but I could’t figure it out by googleing and searching the forums.

I would like to sort the different classes in subfolders of the project (eg. gui, algorithm) and then import them into my main project. I found that theres an “import” but it seems to be for librarys only.
Thanks in advance

I don’t believe you can import classes. Instead you could create tabs on your program to store each class.

1 Like
  • PDE’s Java Mode recognizes 2 file extensions: “.pde” & “.java”.
  • However, we can’t place them in subfolders. They have to be in the root folder.
  • All “.pde” files are concatenated together as 1 “.java” file by the PDE’s pre-processor before compilation.
  • Therefore, we can’t use import for classes/interfaces inside “.pde” files.
  • We are allowed to use import for classes/interfaces inside “.java” files.
  • But it’s completely optional to do so on Processing.

It is too bad that you cannot put .pde and .java files in the /code folder, the way that you can add .jar files.

I understand why this is done with .pde files from a UI perspective, as they are created as new tabs, and they need a consistent place to appear (and to be consistently visible to new programmers).

However with .java it seems like being able to treat them as /code resources could sometimes help to keep sketches tidy.

1 Like

Yes. Its the first time im actually creating a bigger project with processing and it kinda bothers me that I cannot split the GUI part and the algorithm part into different subfolders. Its not a huge problem, just not the way I’d like it to be :stuck_out_tongue:

Processing’s IDE (PDE) was not targeted for big projects. :disappointed:
Hence its “.pde” files are simply called sketches. :woozy_face:
If it’s getting too clunky you should consider moving your project to another more appropriate IDE. :flushed:

1 Like

@delsey – Two common Java IDEs to use for larger projects are Eclipse and IntelliJ IDEA. There is some Processing documentation on working with Eclipse – for example, the Processing Library Template.

A downside (if it is a downside for you) is that, if you structure larger projects in a Java IDE, there is no merging multiple .pde files from subfolders (at least, as for as I am aware).

Instead, you will be writing your classes as .java files in Java rather than using Processing syntax (so writing public in front of things, no color sugar word for int color data, explicitly passing in this rather than having automatic inner classes, et cetera).

1 Like

I started with java and went to processing because my project is about rendering and moving alot (thousands) of objects which is just pretty diffictult in java. (or at least easier in processing) I really dont care about the structure as long as it works, but i wouldve prefered it to be tidy. Thats not a reason for me to change ide’s mid-development, especially since no one is every going to look at the code of this.