JShell หรือที่เรียกว่า REPL (Read-Evaluate-Print-Loop) เป็นเครื่องมือที่นำมารวมใน Java 9 ซึ่งช่วยให้เราสามารถรันโค้ด Java และได้ผลลัพธ์ทันทีโดยไม่ต้องสร้างโปรเจกต์ใหม่ คอมไพล์หรือบิลด์ เราสามารถประเมินนิพจน์ ใช้ import กำหนดคลาส เมธอด และตัวแปรได้อย่างรวดเร็ว
เราสามารถแสดงรายการ คลาส อินเทอร์เฟซ และ enum ทั้งหมดที่กำหนดใน เซสชัน JShell ปัจจุบัน โดยใช้คำสั่ง /types
ตัวอย่างการสร้างคลาส อินเทอร์เฟซ และ Enum
C:\Users\User> jshell
| Welcome to JShell -- Version 9.0.4
| For an introduction type: /help intro
jshell> class Test {
...> public static void main(String args[]) {
...> System.out.println("TutorialsPoint");
...> }
...> }
| created class Test
jshell> interface TestInterface {
...> public void sum();
...> }
| created interface TestInterface
jshell> enum EnumTest {
...> TUTORIALSPOINT,
...> TUTORIX
...> }
| created enum EnumTest
การใช้คำสั่ง /types เพื่อแสดงรายการประเภท
jshell> /types
| class Test
| interface TestInterface
| enum EnumTest
jshell>
คำสั่ง /types จะแสดงรายการประเภทข้อมูลที่ผู้ใช้สร้างขึ้นในเซสชัน JShell ปัจจุบันเท่านั้น ไม่รวมคลาสจากไลบรารีมาตรฐานหรือไลบรารีภายนอก