Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

jshell: The Java Shell (Read-Eval-Print Loop)

Tags: jshell java tool

                         In this article we will discuss about jshell(Java Shell) Java 9 feature. We can explore jShell with JDK 9 Early Access Release.  As of now the general availability of JDK9 is scheduled to 27th July, 2017. The jShell feature is proposed as part of JEP 222. The motivation behind jshell is to provide interactive command line tools to explore the features of java quickly. It is very useful tool to get the glimpse of Java features very quickly for the new learners. Already Java is incorporating functional programming features from Scala. In the same direction they want REPL(Read-Eval-Print Loop) interactive shell for Java as Scala, Ruby, JavaScript, Haskell, Clojure, and Python.

                       The jshell tool will be a command-line tool with features like, a history of statements with editing, tab completion, automatic addition of needed terminal semicolons, and configurable predefined imports.

After downloading the JDK 9, set the PATH variable to access jshell. Now, we will see how to use jshell. Below is the simple program using jshell. We no need to write a class with public static void main(String[] args) method to run simple hello world application.

Now we will write method which will add two variables and invoke method via jshell.

Now, we will create a static method with StringBuilder class without importing it, as jshell does that for you.

I hope you enjoyed jshell feature. In the next article we  will see another JDK 9 feature. Till then, Stay Tuned!!!




This post first appeared on Smart Techie | My Thoughts, My Work, My Ideas, please read the originial post: here

Share the post

jshell: The Java Shell (Read-Eval-Print Loop)

×

Subscribe to Smart Techie | My Thoughts, My Work, My Ideas

Get updates delivered right to your inbox!

Thank you for your subscription

×