โ— Shell
clean mode source โ†—

JShell for prototyping

Code Comparison

// 1. Create Test.java
// 2. javac Test.java
// 3. java Test
// Just to test one expression!
$ jshell
jshell> "hello".chars().count()
$1 ==> 5
jshell> List.of(1,2,3).reversed()
$2 ==> [3, 2, 1]

Why the modern way wins

โšก

Instant feedback

Type an expression, see the result immediately.

๐Ÿ“

No files needed

No .java files, no compilation step.

๐Ÿ”

API exploration

Tab completion helps discover methods and parameters.

Old Approach

Create File + Compile + Run

Modern Approach

jshell REPL

JDK Support

JShell for prototyping

Available

Widely available since JDK 9 (Sept 2017)

How it works

JShell is a Read-Eval-Print Loop for Java. Test expressions, experiment with APIs, and prototype code without creating files, compiling, or writing a main method. Tab completion and inline docs included.

Related Documentation