How to use Processing 4 with Java and Gradle

How to use Processing 4 with Java and Gradle

Processing has been a favorite in the world of creative coding, traditionally using the Java programming language. While there are modern alternatives like Kotlin, Java remains a powerful and widely-adopted choice.

In this guide, we’ll walk through the steps to set up a Processing project with Java and Gradle.

Note: This blog post is meant for people looking how to integrate processing4 with Java. Look here for a Kotlin gradle guilde.


  • You should have Gradle installed on your machine.

Getting Started

1. Cloning the Template from GitHub

First use the template and create a new repository based of the

processing-java-template-1024x651 How to use Processing 4 with Java and Gradle

Clone the repository locally:

git clone<YOUR USERNAME>/ProcessingGradleJava.git
cd ProcessingGradleJava

Replace <YOUR USERNAME> with your GitHub username. If you have renamed the repository, make sure to update it inside the command as well.

2. Editing the Sketch File

Navigate to src/main/java/org/example/ with your favorite editor. You should find the file with the following code:

processing4-java-navigation How to use Processing 4 with Java and Gradle

Start by adding your Processing logic. For instance, to draw a moving ellipse:

package org.example;

import processing.core.PApplet;

public class Processing extends PApplet {
    private float x = 0;

    public static void main(String[] args) {

    public void settings() {
        size(800, 600);

    public void setup() {

    public void draw() {
        fill(255, 0, 0);
        ellipse(x, height / 2.0f, 50, 50);
        x += 5;
        if (x > width) x = 0;

3. Running the Sketch with Gradle

After you’ve edited your sketch, it’s time to run it. Inside the root directory execute the following command.

gradle run

Gradle will compile and run the sketch. You should see a window pop up displaying the Processing canvas with your visualizations.

processing-ball How to use Processing 4 with Java and Gradle


Java and Processing have a long-standing relationship in the realm of creative coding. Integrating them with Gradle allows developers to manage dependencies and build projects efficiently. Dive into the world of visual art with Java, Processing, and Gradle and bring your ideas to life.

Share this content:

Leave a Reply

Your email address will not be published. Required fields are marked *