Usage of JShell
Usage of JShell
The Java Shell tool (JShell) is an interactive tool for learning the
Java programming language and prototyping Java code.
12/12/2022
Why use Jshell?
3 Jshell has reduced all the efforts that are required to run a Java program
and test a business logic.
Using JShell, you can enter program elements one at a time, immediately
see the result, and make adjustments as needed.
JShell helps you try out code and easily explore options as you
develop your program. You can test individual statements, try out
different variations of a method, and experiment with unfamiliar APIs
within the JShell session.
12/12/2022
Start and exit JShell
5
To start Jshell, open terminal in Linux or command prompt in
windows and type “jshell” . It will start jshell session and displays a
welcome message to the console.
12/12/2022
Snippets
6
JShell accepts Java statements; variable, method, and class
definitions; imports; and expressions. These pieces of Java code are
referred to as snippets.
12/12/2022
Don’t use in JShell
7
Can't write Package Statement
12/12/2022
References link for JShell
8
https://docs.oracle.com/javase/9/jshell/introduction-jshell.htm#JSHEL-
GUID-630F27C8-1195-4989-9F6B-2C51D46F52C8
https://www.javatpoint.com/java-shell-tool
12/12/2022