Running Jshell on Windows - A Hands-on Tour


jshell (Kulla) is the official  REPL command line tool in JDK 9.  This is the most exciting feutre of Java 9 among others. The tool comes with the JDK 9 so you can find it  in C:\Program Files\Java\jdk-9\bin


  1. Download the JDK 9 Early access
  2. Launch the jshell from command line 
Lets write our first traditional System.out.println("Hello world")


Boom, it works.
it returns us the text "Hello World" but if you noticed i omitted the semicolon here, yes you here me right. You can omit semicolons here.

Beside writing Hello world, You can actually write some useful code here.
You can import things , You can assign values , You can create Objects here.

Say for Example you want to add two numbers then you can direct into the terminal.

int a = 10
int b = 20
a+b and you will be presented with the result


as the same you can create Objects. for example File file = new File("alice.txt")


Now again if you noticed we did not import java.io.File here but it works, it works fine with official classes but at this moment i do not know how to deal with external libs.
Lets play around. if you know how to do that feel free to comment..

and finally you can type the code in jshell that will actually do some processing



No comments :

Post a Comment