Java 9 : JShell (REPL) feature

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:

  1. Write your Java code
  2. Compile the code and check/fix erros (If any)
  3. Run the program
  4. Check the result and if its wrong
  5. 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)

Start Java JShell REPL

It will start the CLI of JShell

JShell Inline Programming – Java REPL

To stop the JShell type below command in CLI

Exit Java REPL – JShell


One comment

Join Discussion

This site uses Akismet to reduce spam. Learn how your comment data is processed.