JShell เป็นเครื่องมือ REPL ใน Java 9 รันโค้ด Java ได้ผลทันที สามารถ ประเมินนิพจน์ หรืออัลกอริทึมง่ายๆ ได้โดยไม่ต้องสร้างโปรเจกต์ คอมไพล์หรือบิลด์ รันนิพจน์ ใช้ import กำหนดคลาส เมธอด ตัวแปรได้ เป็นส่วนหนึ่งของ Java 9 JDK แต่ไม่ใช่ JRE
เริ่มเซสชัน JShell ใน command prompt ด้วย jshell คำสั่งต่างๆ: /exit ออกจากเซสชัน /reset รีเซ็ต JShell /reload รีโหลด /imports ดู imports
ตัวอย่าง: พิมพ์ดาวด้วย for loop
C:\Users\User>jshell
| Welcome to JShell -- Version 9.0.4
| For an introduction type: /help intro
jshell> for(int i=0; i<10; i++) {
...> for(int j=0; j<=i; j++)
...> System.out.print("*");
...> System.out.println("");
...> }
*
**
***
****
*****
******
*******
********
*********
**********
ตัวอย่างเพิ่มเติม: รูปแบบอื่นๆ
พีระมิด (Pyramid)
jshell> for(int i=1; i<=5; i++) {
...> for(int j=1; j<=5-i; j++) System.out.print(" ");
...> for(int k=1; k<=2*i-1; k++) System.out.print("*");
...> System.out.println();
...> }
*
***
*****
*******
*********
สามเหลี่ยมถอยหลัง
jshell> for(int i=5; i>=1; i--) {
...> for(int j=1; j<=i; j++) System.out.print("*");
...> System.out.println();
...> }
*****
****
***
**
*
JShell เหมาะสำหรับทดลองอัลกอริทึม วนลูป และ logic ต่างๆ ได้ทันที