JShell (A new Java 9 concept)

The Java community is the largest programming community in the world and Java is adding more and more features which is making it a powerful programming language and keeping ahead with other programming languages. Java 9 has become more powerful with the introduction of JShell Java’s REPL (read-evaluate-print loop).

What is JShell?

JShell provides a fast and friendly environment that enables us to quickly explore, discover and experiment with Java language features and its extensive libraries. Concept of REPL is not new and it’s around for decades. In 1960’s LISP had concepts of REPL which is now brought into Java.

JShell replaces the tedious cycle of editing. Compiling and executing with its read-evaluate-print loop. We just focus on writing JShell commands and Java code snippets. When we enter a snippet, JShell immediately read it, evaluates it and prints the results so that we can see the effects of our code immediately. Then it loops to perform this process again for the next snippet. JShell brings this right down to the individual snippet level. Your code literally comes alive as you enter each line. We will still make occasional errors as we enter our snippets. JShell reports compilation errors to us on a snippet-by-snippet basis. We can use this capability, for example, to test the items in our Common Programming Error tips and see the errors as they occur.

What are snippets?

Snippets can be expressions, individual statements, multi-line statements and larger entities like methods and classes. JShell supports all but a few Java features, but there are some differences designed to facilitate JShell’s explore–discover–experiment capabilities. In JShell, methods do not need to be in classes, expressions and statements do not need to be in methods, and you do not need a main method.

Where is JShell useful?

Professional developers will commonly use JShell for rapid prototyping but not for full-out software development. Once you develop and test a small chunk of code, you can then paste it in to your larger project.

Conclusion

Java 9 and its JShell are early access technologies that are still under development. But by this we can see what Java 9 will consists of and where Java is heading to in programming world.


To view or add a comment, sign in

More articles by Ravi Kiran Reddy Katkuri

  • Multiple inheritance with interfaces in Java 9 (Classic Diamond Problem)

    The default methods in Java 8 were introduced to support backward compatibility of interfaces. Some of the interfaces…

  • Changes to interfaces in Java 9

    With Java SE 8, for the first time developers are able to add implementations to interface methods and label them as…

  • Reactive Programming

    Now a day’s reactive programming is trending. Libraries and frameworks in various programming languages are being…

    2 Comments

Explore content categories