JDK 9 is planning to add JShell for REPL(Read-Eval-Print Loop) functionality in Java platform.
JShell is a command-line tool for quickly running statements.
JShell provides a way to interactively evaluate declarations, statements, and expressions in Java. So, we don’t need to create a class with main method to test some code.
Getting started with JShell
To get started with JShell, download JDK 9 from https://jdk9.java.net/
Once you have updated your JAVA_HOME to point to your JDK 9 installation, you can type “jshell” in command prompt to get started.
To exit JShell, type /exit and hit enter
You can also check all the available commands using /help
You can declare variables and type expressions involving them to see the results.
And JShell also has a very helpful tab-completion, automatic addition of needed terminal semicolons, and configurable predefined imports and definitions.
- Learning Java
The immediate feedback is useful for new developers learning Java language in comparison to creating a test class with main method and adding System.out.println to check the values.
- Rapid prototyping
JShell facilitates prototyping and exploration of coding options with immediate results and feedback. For any changes to the classes, we can quickly update the cladd definitions, reset and try it again.
© 2017, https:. All rights reserved. On republishing this post, you must provide link to original post