How to set a verbose mode in JShell in Java 9?


JShell is the REPL tool that has introduced in Java 9. We can use this tool to execute simple snippets in the command-line prompt.

When we enter an arithmetic expression, variable, etc in JShell, then it displays the result without details of the type of variable created. It is possible in JShell to display more information about the execution of an entered command, use verbose mode. We need to obtain more information on the commands executed by using the command: "/set feedback verbose" (the command can be preceded by "/").

In the below snippet, the verbose mode is on, and it can able to display more information about the type of variable.

C:\Users\User>jshell
| Welcome to JShell -- Version 9.0.4
| For an introduction type: /help intro

jshell> /set feedback verbose
| Feedback mode: verbose

jshell> 5.0 * 8
$1 ==> 40.0
| created scratch variable $1 : double

jshell> String str = "TutorialsPoint";
str ==> "TutorialsPoint"
| created variable str : String

jshell> void test() {
...> System.out.println("Tutorix");
...> }
| created method test()

jshell> test()
Tutorix

jshell> String str1 = new String("Tutorix");
str1 ==> "Tutorix"
| created variable str1 : String

jshell> "TutorialsPoint" + "Tutorix" + 2019
$6 ==> "TutorialsPointTutorix2019"
| created scratch variable $6 : String

jshell> int test1() {
...> return 10;
...> }
| created method test1()

jshell> test1()
$8 ==> 10
| created scratch variable $8 : int

Updated on: 06-Apr-2020

252 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements