Sitemap
Sachin Mahor

Sachin Mahor

My name is Sachin Mahor. I have done my MCA from NIT Jamshedpur.

Jshell REPL in Java

1 min readJun 13, 2025

Jshell is a REPL(Real-Eval-Print-Loop) tool introduced in Java. Jshell provides a shell for evaluating Java expressions and statements. Jshell is used for experimenting with Java code, new features and learning Java programming.

Steps of stating Jshell

  1. Install JDK 9 or Latest: Download JDK from the Oracle website. And install in the system.
  2. Open the Terminal/ Command Prompt: Open Command Prompt using CMD or using VS code terminal.
  3. Launch Jshell: Type Jshell in terminal and enter.

Basic Commands

Get Sachin Mahor’s stories in your inbox

Join Medium for free to get updates from this writer.

Starting Jshell

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

Evaluation

jshell> 5 + 2
$1 ==> 7

jshell> String name = "Sachin Mahor"
name ==> "Sachin Mahor"

Creating Method

jshell> int sum(int a, int b){
...> return a + b;
...> }
| created method sum(int,int)

jshell> sum(10, 20);
$4 ==> 30

Check Variable

jshell> /vars
| int $1 = 7
| String name = "Sachin Mahor"
| int $4 = 30

Importing Package

jshell> List<String> names = Arrays.asList("Raju", "Kamal", "Pinki");
names ==> [Raju, Kamal, Pinki]

jshell> for(String name: names){
...> System.out.println(name);
...> }
Raju
Kamal
Pinki

Exiting fro Jshell

jshell> /exit
| Goodbye

Jshell is a tool for testing the java code without writing whole code. You can read more about Jshell. There are lot more commands.

--

--

Sachin Mahor
Sachin Mahor

Written by Sachin Mahor

My name is Sachin Mahor. I have done my MCA from NIT Jamshedpur.