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!");
}
}
Build and run with an IDE
IntelliJ IDEA
macOS users should start their application passing -XstartOnFirstThread
as a VM option.
Tested on IntelliJ IDEA Community 2021.3.3.
Eclipse
macOS users should start their application passing -XstartOnFirstThread
as a VM option.
Tested on Eclipse 4.23.
Build and run from the command line
- Windows
- macOS
- Linux
.
├── 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/.
.
├── HelloRectangle.java
└── p8g.jar
javac -cp p8g.jar HelloRectangle.java
java -XstartOnFirstThread -cp .:p8g.jar HelloRectangle
Tested on macOS Mojave 10.14.6 with OpenJDK installed via brew install --cask temurin
.
.
├── HelloRectangle.java
└── p8g.jar
javac -cp p8g.jar HelloRectangle.java
java -cp .:p8g.jar HelloRectangle
Tested on Ubuntu 20.04.3 LTS with OpenJDK installed via sudo apt install temurin-17-jdk
.