Java Timer Example - Cheerpj Typing CST Test
Loading…
Java Timer Example — Cheerpj Code
Uses a timer to print current time every second.
# cheerpj/demo/Timer.java
import java.util.Timer;
import java.util.TimerTask;
import java.util.Date;
public class TimerExample {
public static void main(String[] args) {
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
System.out.println(new Date());
}
}, 0, 1000);
while(true) {}
}
}Cheerpj Language Guide
CheerpJ is a WebAssembly-based Java-to-JavaScript/WebAssembly compiler and runtime that allows running unmodified Java applications directly inside the browser without plugins. It converts Java bytecode into WebAssembly + JavaScript, enabling full client-side execution of existing JVM applications, applets, and libraries.
Primary Use Cases
- ▸Running legacy Java Swing/AWT desktop apps in the browser
- ▸Migrating Java Applets to modern WebAssembly environments
- ▸Enterprise internal tools requiring Java libraries
- ▸Embedding Java libraries inside JS/Wasm web apps
- ▸Preserving old JVM-based simulations, tools, and educational software
Notable Features
- ▸Convert Java bytecode directly into Wasm + JavaScript
- ▸Full Java runtime emulation in browser
- ▸Supports Swing and AWT UI rendering
- ▸Works without plugins or local JVM
- ▸Can run unmodified .jar files client-side
Origin & Creator
CheerpJ is developed by Leaning Technologies, known for compiling traditional languages to modern web targets like WebAssembly.
Industrial Note
CheerpJ is heavily used by enterprises wanting to preserve legacy Java Swing/AWT applications or Java applets and make them run in modern browsers without rewriting them.