1.

JShell in Java 9

Answer»

JShell is a FEATURE introduced in Java 9. JShell provides Java with REPL ability. REPL STANDS for Read-Eval-Print-LOOP. With REPL, we can test java based logic and expressions without any requirement of compiling.

REPl is acts as an immediate feedback loop and can have a great effect on productivity in that particular language.

Now let us play around with JShell for a bit.

Running JShell on Windows

Step 1: Setup the JDK path

Go to Control Panel > System > Advanced System Settings > Advanced tab > Environment Variables.

Under System Variable, click Path, then New and add the following JDK path,

C:\Program Files\Java\jdk-11.0.1\bin

Step 2: Now open Command Prompt and type jshell.

Step 3: Viewing the JShell commands
Type /help in the command window once JShell start running:

Step 4: Running jshell commands

Type /imports in the jshell command window for obtaining the packages imported by jshell

Step 5: Performing CALCULATIONS in jshell

Try simple arithmetic calculations with jshell

Step 6Creating functions in jshell

You can create functions and use them in jshell

Step 7: Exiting jshell

To exit jshell, type /exit



Discussion

No Comment Found