Browsed by
Month: August 2026

Think Java, but interactive

Think Java, but interactive

The online version of Think Java now features interactive widgets that run the code examples in the browser. For readers, it means you can try out the examples, modify them, and test your code. And for us it means we can publish an interactive version of the book without providing servers.

The widgets use java-runner, an in-browser Java editor and interpreter developed by Think Java co-author Chris Mayfield.

java-runner implements a subset of Java with the features needed for most programming classes, plus some safety features — like a maximum instruction count to stop infinite loops. It provides a code editor and a REPL.

Here’s an example of the code editor, from Section 6.1:

And here’s an example of the REPL, from Section 6.6::

We’re aware of one example where the behavior of java-runner differs from the Java language specification — so we’re working on that.