Some weeks ago, NetBeans 8.2 had been released. Currently a patch version is available. Although NetBeans has moved to Apache, it is still developed by the NetBeans team and a vibrant community. So, let’s look at a great feature of the future version: The Java Shell.
Today I’m not talking about the command line tool called JShell, which is part of Java 9. However, JShell is not only a command line tool, but an API which can be used in other applications. Since JShell is written in Java, it can be used right now. And this is what you find within the current NetBeans development version . The Java Shell is integrated into NetBeans and offers lots more comfort than the command line version. There is no need to wait for Java 9. You may run NetBeans including the Java Shell by Java 8.
There a two different ways to invoke the Java Shell:
- From the menu Tools, Open Java Platform Shell
- Within the project tree’s context menu Execute Java Shell
Both will open the Shell, but with different contexts. Either the NetBeans platform or your application. The following series of screenshots will illustrate the second choice.
In the presented example, it is not possible to create a new instance of the PersonManager by new PersonManager(), but you can retrieve the instance of the singleton object. NetBeans investigates the source and offers the correct autocompletion within the shell.
After you developed some code interactive, you may want to persist it into the application. There is no need for some copy-paste-loose actions. NetBeans is able to save the session context into a class.
By the way, the PersonManager is part of the little application I used to explain Java Lambdas and Parallel Streams .
I’ll continue to observe the Java Shell withing NetBeans and to share some highlights with you.