This content is part of the Essential Guide: News from JavaOne 2016

JShell: Adding REPL capabilities to the JDK

At JavaOne 2016, Oracle's chief architect of the Java platform group, Mark Reinhold, discusses the addition of JShell. Learn why he's excited.

For software developers, JavaOne doesn't really start until Mark Reinhold, chief architect of the Java platform group at Oracle, takes to the keynote stage. While there are always C-level executives providing overviews and forward-thinking statements to the JavaOne audience before him, it's not until Reinhold takes the stage that the low-level topics that resonate with software developers are given the detailed coverage for which developers come to JavaOne.

For many, there's nothing quite as boring as scripting. There's nothing sexy about writing batch files. But that's not dampening the enthusiasm Reinhold is conjuring up over JShell, the new scripting framework that greatly simplifies the task of writing small, easily executed programs. Until now, Groovy-like simplicity has been sorely missed in the Java EE work. With JShell, that type of simplicity will arrive.

What's the point of JShell?

JShell and its read-eval-print loop, or REPL, capabilities in the Java 9 programming language make it simple to evaluate small code snippets -- something that's surprisingly frustrating to do with a Java compiler. With JShell, developers will soon have a fast way to demo specific functionalities, easily run new code and run specific pieces of code to see if the result is what the developer expected. JShell provides instant feedback -- a welcome addition to the next iteration of the Java Development Kit (JDK).

So, how easy is it to start working with JShell? "You can run a build inside a shell. You can type in your code, and it will evaluate, print and tell you what's what," Reinhold said. With an assortment of helpful and sensible imports, and even auto-completion help, Reinhold's live demo at the JavaOne keynote effectively demonstrated how simple it is to execute and evaluate an expression, variable or complex statement.

Self-referencing can come in handy

Another neat feature: With JShell, dollar signs and hash codes act almost like bookmarks for expressions, providing interscript awareness. The notation allows the programmer to refer to the value of a past expression within the JShell session, making it simple to build on previously developed scripts, while digging deeper into code and logic without having to do a lot of housekeeping.

Unleashing the explorer at the desktop

So, why are developers so excited about JShell? It really comes down to the fact that JShell allows developers to do what they love doing, which is writing code, trying out new approaches to problems, testing their hunches and verifying their bytecode hypotheses. "JShell is designed for exploratory programming," Reinhold said, and exploratory programming is what all of the best developers love to do. JShell has been a long time coming, but it is certainly a welcome addition to the JDK.

Next Steps

At JavaOne with Bert Ertman

Looking at Jenkins World to JavaOne 2016

How the benefits of microservices are growing

Dig Deeper on Development tools for continuous software delivery

App Architecture
Software Quality
Cloud Computing
Security
SearchAWS
Close