Skip to main content

Java

Hello rectangle!

HelloRectangle.java
import io.github.bernhardfritz.p8g.Sketch;

public class HelloRectangle extends Sketch {
@Override
public void draw() {
background(220);
rect(50, 50, 100, 100);
}

public static void main(String[] args) {
Sketch sketch = new HelloRectangle();
sketch.run(320, 320, "Hello rectangle!");
}
}
ScreenshotScreenshot

Build and run with an IDE

IntelliJ IDEA

IntelliJ project settings

macOS users should start their application passing -XstartOnFirstThread as a VM option.

IntelliJ run configuration

Tested on IntelliJ IDEA Community 2021.3.3.

Eclipse

Eclipse project settings

macOS users should start their application passing -XstartOnFirstThread as a VM option.

Eclipse run configuration

Tested on Eclipse 4.23.

Build and run from the command line

.
├── HelloRectangle.java
└── p8g.jar
javac -cp p8g.jar HelloRectangle.java
java -cp .;p8g.jar HelloRectangle

Tested on Windows 10 with OpenJDK installed from https://adoptium.net/.