Java REPL Tools: A Practical Comparison
Java has several solid REPL implementations available. Here are the main options and how to use them.
jshell (Official)
The best choice for most users is jshell, included in JDK 9+. It’s the official interactive shell for Java and comes with every modern Java installation.
Start it immediately:
jshell
Basic usage:
jshell> long ts = System.currentTimeMillis() / 1000;
ts ==> 1491474800
jshell> System.out.println("Current time: " + ts);
Current time: 1491474800
jshell> int[] numbers = {1, 2, 3, 4, 5};
numbers ==> int[5] { 1, 2, 3, 4, 5 }
jshell> java.util.Arrays.stream(numbers).sum()
$6 ==> 15
jshell handles most Java syntax seamlessly—you can declare variables, define methods, create classes, and execute arbitrary code without boilerplate. Tab-completion works well for method names and packages.
Useful jshell commands:
jshell> /help # Show all commands
jshell> /vars # List all variables
jshell> /methods # List all methods you've defined
jshell> /list # Show command history
jshell> /save myfile.jsh # Save session to file
jshell> /open myfile.jsh # Load a previous session
jshell> /exit # Leave jshell
Load external libraries by adding them to the classpath at startup:
jshell --class-path ".:lib/*"
java-repl (Third-party Alternative)
If you’re stuck on Java 8 or need additional features, java-repl (https://github.com/albertlatacz/java-repl) is still functional though no longer actively maintained.
wget --quiet https://github.com/albertlatacz/java-repl/releases/download/428/javarepl-428.jar -O /tmp/javarepl-428.jar
java -jar /tmp/javarepl-428.jar
It works similarly to jshell but with some differences in command syntax (:help instead of /help).
Groovy Shell (groovysh)
For a more Pythonic experience with Java interoperability, Groovy provides groovysh:
groovysh
Groovy syntax is more concise than Java:
groovy> def numbers = [1, 2, 3, 4, 5]
groovy> numbers.sum()
==> 15
groovy> "Hello ${numbers.size()} items".toString()
==> Hello 5 items
Kotlin REPL (kotlinc -interactive)
If you have Kotlin installed, its REPL is excellent:
kotlinc -J-Xms128m -J-Xmx512m
Kotlin’s syntax is clean and it integrates seamlessly with Java libraries.
Recommendation
Use jshell unless you have a specific reason not to. It’s built-in, well-maintained, and handles imports, classpath management, and complex expressions gracefully. It’s the de facto standard for Java REPL work in 2026 and beyond.
For Java 8 systems (rare nowadays), fall back to java-repl or upgrade to a modern JDK.
