When calling println etc. from an external Java class file in Processing



If you have developed it comfortably by classifying it properly with Processing, standard functions such as println () from an external Java class file (strictly speaking, the methods defined under processing.core.PApplet) Can't be used! I thought, so I looked it up a little.


This is my environment now. I think that there is basically no problem in other environments.

About Processing

Processing is a language / environment where you can easily code and learn in visual arts. It has been under development since 2001 and has contributed to improving software literacy in visual arts and art literacy in technology. Many students, artists, designers, researchers and hobbyists are now learning and prototyping with Processing. (Appropriate translation of the explanation of Official Site)

In other words, it's a very fun and wonderful environment where you can do art and prototyping quickly.


Currently, as far as I know, I import processing.core.PApplet into an external Java class file where I want to use the function, and have an instance of PApplet (an instance of the base class / entry point class) inside the class. , I think it's a good idea to call the function from that instance. In other words, if you create a project with Test.pde and create a class file called Human.java in the same directory,


void setup() {
  Human Oka = new Human();

void draw() { }


public class Human {
  public Human() {
    println("ware umaretari"); //This makes me angry if println is not defined



void setup() {
  Human Oka = new Human(this);

void draw() { }


import processing.core.PApplet;

public class Human {
  PApplet parent;
  public Human(PApplet p) {
    this.parent = p;
    this.parent.println("ware umaretari");

That's good!


I will continue to do my best so that I can use it in a core way (?). I would appreciate it if you could tell me if there is a more clever way. By the way, I knew that I could call a method from the base class (Test class in this example), but could there be a more general way? I noticed that I was supposed to pass my instance in the constructor of ControlP5.


PApplet Javadocs Control P5 git repository

Recommended Posts

When calling println etc. from an external Java class file in Processing
File path is not recognized when executing an external command from a Java application
About file copy processing in Java
Run an external process in Java
Symbol not found error when new class in another Java file
GetInstance () from a @Singleton class in Groovy from Java
Java method call from RPG (method call in own class)
How to get Class from Element in Java
Cause of is not visible when calling a method of another class in java
Try calling synchronized methods from multiple threads in Java
Behavior when calling Java variadic methods from Scala / Kotlin / Java
Call a program written in Swift from Processing (Java)
Implement Java Interface in JRuby class and call it from Java
Easily get an integer from a system property in Java
Generate Stream from an array of primitive types in Java
Get a non-empty collection from an Optional stream in java
Measured parallel processing in Java
External process execution in Java
[java] What I did when comparing Lists in my own class
Text file placed in resources in Java cannot be read when jarted
How to get the length of an audio file in java