Using Processing in NetBeans

Processing, is known to work in Eclipse IDE with proper procedures. However, now everyone have Eclipse. Some people use NetBeans and such.

This brief tutorial shows you how to use Processing with NetBeans.

First, create a new Java Application project as usual.

Screenshot

Creating a Project

Then, go to Project Properties, Libraries, Compile tab, and click “Add JAR/Folder”.
Now, you need to find where is the Processing core.jar. It is located in the $PROCESSING/lib/core.jar, (where $PROCESSING = the Processing installation directory) for Windows and Linux users.
Reference as “Absolute Path” option on the right is recommended.

Screenshot

Adding a library

After you added the library, you can write Processing code.
Notice how the setup and draw methods are inside the class and are public.

Here is an example:

package processingtest;
import processing.core.*;
 
public class Main extends PApplet {
 
	// avoids the serial warning
	public static final long serialVersionUID = 209923952409623L;
 
	// @Override is required for newer Java versions
	@Override
	public void setup() {
		size(640, 480);
	}
 
	@Override
	public void draw() {
		background(0);
		rectMode(CENTER);
		fill(0xFFFFAA99);
		rect(mouseX, mouseY, 100, 100);
	}
 
	// main method to launch this Processing sketch from computer
	public static void main(String[] args) {
		PApplet.main(new String[] { "processingtest.Main" });
	}
}

You can also learn by looking at the transformed Java code by Processing: Seek_Arrive.java

Of course, there are much more details to cover, they are basically as same as the Processing in Eclipse tutorial, to create multiple classes and using the color type, please read that tutorial.


One Response to “Using Processing in NetBeans”

Leave a Reply