How to create a Processing 4 library using Intellij IDEA
Trying to create a Processing library using anything but Eclipse is a challenge, but this tutorial explains one way to easily do it using Intellij IDEA.
Prerequisites
- Intellij IDEA installed
- Downloaded and extracted Processing 4 or later
Tutorial
First, download or clone the Processing library template and open it in Intellij.
If Intellij doesn’t recognize the project immediately, go to File > Close Project, on the welcome window press Ctrl+Shift+A to open Intellij Actions and find “Import Project from Existing Sources…” and find where your project is saved.
When you choose your project, an “Import Project” window shows up. Select “Import project from external model”, Eclipse as the model and click on Next until the selection of the project SDK. You must choose JDK 17 or later for Processing version 4 or later and click “Create”. Now Intellij should import project succesfully.
Next your library needs Processing core library to work. Find where you have your Processing installed and look for core/library folder. Copy the core.jar file to the lib folder in the project, right click it, select “Add as Library…” and click “OK”. Opening src/template/library/HelloLibrary should not give any errors now.
To build the library we need Apache Ant. Easiest way is to install Ant plugin in Intellij Settings. You can open the Ant window by going to View > Tool Windows > Ant.
Now is a good time to check out resources/build.properties in your project and change the build properties for the library. The one you need to change for the library to work is classpath.local.location. For example if my project is on “C:/Users/Medium/projects/library” the property should be:
classpath.local.location=C:/Users/Medium/projects/library/lib
#or
#classpath.local.location=${user.home}/projects/library/lib
If Ant does not recognise your resources/build.xml file immediately try right clicking on the file, selecting “Override File Type” and search for XML. Ant window should now contain Processing Library item. Run the build by pressing green arrow in the window or by right clicking Processing Library and selecting “Run Build”.
That’s it. If you followed the tutorial you should have a built Processing 4 library which you can share and use in other Processing projects. The built files are in the distribution folder in the root of the project.
Hope it helped you in some way!