We heard a lot about REPL when we were developing AngularJS app or NodeJS app. Which works on Read-Evaluate-Print-Loop mechanism.
Java Shell tool is an interactive tool for learning Java and prototyping java code. JShell works on REPL mechanism which evaluates declarations, statements, and expressions as they are entered and immediately shows the results. The tool is run from the command line.
Earlier Java program used to follow below steps:
- Write your Java code
- Compile the code and check/fix erros (If any)
- Run the program
- Check the result and if its wrong
- Update the code again and repeat the 1-5 steps again.
Jshell will replace this, You can test your logic in this JShell command and check the result instantly and make required changes and it will automatically show you the updated results without worrying about traditional process of compile/run java program.
To start the JShell write below command (Make sure you set the JAVA_HOME path to jdk-9 path)
It will start the CLI of JShell
To stop the JShell type below command in CLI