At this point you’ve probably used Processing through the Processing editor, which allows you to write Processing code and automatically run it. You’ve also learned how to use Java libraries, which allow you to use classes and functions written by other people in your Java code. This tutorial combines those ideas and shows you how to use Processing as a Java library.
@abmushfiq it looks like your error is different from the error that @designer01 is getting.
Your error looks like it’s telling you that it can’t find your class. Can you try creating a more basic project that just prints hello world? I’d try to get that working before you try adding Processing to it.
Behind the scenes, Processing would convert sketch_22017a1 into a Java class, and Bubble into an inner class. I believe if you export your sketch as an application you can see the generated Java code, but I believe it’ll look something like this:
public class sketch_22017a1 {
Bubble b;
void setup() {
size(640, 360);
b = new Bubble();
}
class Bubble {
// code here
}
}
This is why other tabs can access variables like width and height, and functions like ellipse() - because the compiled code is an inner class of the main sketch class.
Now, whether you set your code up that way when you’re using Processing as a Java library is up to you. Generally I would say it’s probably a better idea to have each tab be its own standalone class, and then you’d pass around references to your sketch to have access to variables like width and height, and functions like ellipse().
If you want to create a top-level class in the Processing editor, add .java to your tab name - in your case that would be Bubble.java.
I think this note about settings instead of setup isn’t entirely correct.
I used Processing’s “export application” feature to find the compiled java of a program I wrote which included code in the setup method, and the output java had both a setup and a settings method.
I think settings is mostly just used for canvas size information. if, in the settings method, you try to draw stuff or reference the sketch in other ways you’ll get a null pointer exception.