GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • java.evolved
  • ←
  • →

This view

  • Original page
  • New address

GeezerVison is showing javaevolved.dev — JShell for prototyping | java.evolved

Home / Tooling / JShell for prototyping
Tooling Beginner

JShell for prototyping

  • 🐛 Report a code issue
  • 🌐 Report a translation issue
  • 💡 Suggest a new pattern

Try Java expressions interactively without creating files.

Tooling
Code Comparison
✕ Java 8
// 1. Create Test.java
// 2. javac Test.java
// 3. java Test
// Just to test one expression!
✓ Java 9+
$ jshell
jshell> "hello".chars().count()
$1 ==> 5
jshell> List.of(1,2,3).reversed()
$2 ==> [3, 2, 1]
Share 𝕏
See a problem with this code? Let us know.
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
Since JDK
9
Difficulty
Beginner
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
JShell Tool ↗ JShell (JEP 222) ↗
Related patterns
Tooling Advanced

AOT class preloading

Java 8
// Every startup:
// - Load 10,000+ classes
// - Verify bytecode
// - JIT compile hot paths
// Startup: 2-5 seconds
Java 25
// Training run:
$ java -XX:AOTCacheOutput=app.aot \
    -cp app.jar com.App
// Production:
$ java -XX:AOTCache=app.aot \
    -cp app.jar com.App
Hover to see modern ➜
JDK 25+ →
Tooling Advanced

Compact object headers

Java 8
// Default: 128-bit object header
// = 16 bytes overhead per object
// A boolean field object = 32 bytes!
// Mark word (64) + Klass pointer (64)
Java 25
// -XX:+UseCompactObjectHeaders
// 64-bit object header
// = 8 bytes overhead per object
// 50% less header memory
// More objects fit in cache
Hover to see modern ➜
JDK 25+ →
Tooling Intermediate

Multi-file source launcher

Java 8
$ javac *.java
$ java Main
// Must compile all files first
// Need a build tool for dependencies
Java 22+
$ java Main.java
// Automatically finds and compiles
// other source files referenced
// by Main.java
Hover to see modern ➜
JDK 22+ →
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.