JShell कमांड्स
JShell Java 9 में पेश किया गया पहला REPL टूल है। हम JShell टूल का उपयोग करके कमांड-लाइन प्रॉम्प्ट पर सरल स्निपेट्स निष्पादित कर सकते हैं। jshell कमांड टाइप करके JShell सत्र शुरू करें, /exit कमांड से सत्र रोकें, और /help कमांड से विशेष कमांड खोजें।
/reload कमांड
/reload कमांड JShell में सभी मौजूदा स्निपेट्स को फिर से निष्पादित करने के लिए उपयोग किया जा सकता है। हम /reset कमांड का उपयोग करके JShell सत्र से सभी पूर्व कोड को भी हटा सकते हैं।
स्निपेट्स बनाना
jshell> 2+10
$1 ==> 12
jshell> String s = "Tutorialspoint"
s ==> "Tutorialspoint"
jshell> System.out.println("Tutorialspoint")
Tutorialspoint
jshell> int num1 = 25
num1 ==> 25
jshell> /1
2+10
$5 ==> 12
jshell> /2
String s = "Tutorialspoint";
s ==> "Tutorialspoint"
jshell> /3
System.out.println("Tutorialspoint")
Tutorialspoint
jshell> /4
int num1 = 25;
num1 ==> 25
/reload लागू करना
jshell> /reload
| Restarting and restoring state.
-: 2+10
-: String s = "Tutorialspoint";
-: System.out.println("Tutorialspoint")
Tutorialspoint
-: int num1 = 25;
-: 2+10
-: String s = "Tutorialspoint";
-: System.out.println("Tutorialspoint")
Tutorialspoint
-: int num1 = 25;
-: int num1 = 25;
/reset लागू करना
jshell> /reset
| Resetting state.
jshell>
/reload सत्र को पुनरारंभ करता है और सभी स्निपेट्स को फिर से चलाता है, जबकि /reset स्थिति को पूरी तरह से साफ़ कर देता है।