The Apache NetBeans IDE has made a number of advances since the release of NetBeans 8.2, the last release under Oracle Corporation. The release cadence has stayed closely in-line with the release cadence of Java, and therefore, there has been a number of releases in a short period of time since open sourcing of the IDE. Apache NetBeans 9 focused on modularity support and JShell. Release 10 contained new features such as JDK 11 support and PHP. Apache NetBeans 11 targeted JDK 12 support, Java EE, and Gradle support.
Note
It is important to note that in order to utilize support for a particular JDK release feature, you must be running Apache NetBeans on the same JDK release or a greater JDK release. One can easily set Apache NetBeans to run under a different version of the JDK by setting the netbeans_jdkhome property within the netbeans/etc/netbeans.conf configuration file.
In this chapter, we will take a brief tour covering some of the most important new features of these past few releases. This chapter will not take a deep dive into these features, as the intention is to provide a quick overview. However, many of the features mentioned in this chapter contain larger sections elsewhere in this book, which go into much more detail.
Apache NetBeans 9.0
The significant new features of Apache NetBeans 9.0 included modularity support, local variable type inference, and JShell. In this section, we will provide a brief look into each of these features, giving you a quick look at their usage.
Jigsaw (Modularity) Support
Perhaps the largest new feature of the JDK in its entire lifetime has been the release of the Java Modularity system, better known as Jigsaw. The modularity system in the Java Platform allows one to break down applications into modules, rather than as one large monolithic application.
As part of the module system, the Modulepath has taken precedence over the CLASSPATH. The Modulepath was added to Apache NetBeans in order to provide support for modules, along with compatibility for those applications that still make use of the CLASSPATH.
A standard Java SE project can be made into a module by adding a module-info.java file to its default package. The Apache NetBeans IDE has full support for module-info.java, including auto-completion. There is also an Ant-based project type known as the Java Modular Project. This project type can be used to create a modular application, consisting of a number of modules. To begin, open the New Project wizard, and choose the Java with Ant category, then choose Java Modular Project.
Local Variable Type Inference
Local variable type inference brings the var keyword to the Java language. This allows the developer to declare a var type, while the compiler infers the type from the other local variables in the code. The Apache NetBeans IDE contains a number of features to assist developers in the use of local variable type inference. There are a number of “hints” added to the editor to help signify when code has been typed that would support a changeover to utilize local variable type inference. Hints can be clicked upon to instantly make the suggested changes.
For instance, there is a hint to Replace explicit type with ‘var’, and vice versa. There are also hints to split compound declarations. It is all baked into Apache NetBeans, making code easier to read and manage.
JShell
The JShell was a long overdue feature of the Java language, as many modern languages nowadays have a REPL (Read Eval Print Loop) utility packaged with the distribution. The Java language gained a REPL in JDK 9, and it is known as JShell. This tool provides auto-completion and basic development/testing capabilities. It also allows one to execute Java dynamically on the fly, evaluating statements and blocks of code without compilation. The Apache NetBeans IDE contains support for JShell by providing an instance of the REPL within the editor pane for quick access. To open JShell, use the Tools ➤ Open Java Platform Shell menu option. Once selected, an editor window will open the JShell utility for the Java Platform on which Apache NetBeans is running.
Note
You must be running Apache NetBeans on JDK 9 or greater in order to utilize the JShell utility.
Apache NetBeans 10.0
The Apache NetBeans 10.0 release included a couple of major enhancements, those being JDK 11 and PHP support. In this section, we will take a brief look at each of these features so that you can begin to explore them in their entirety.
JDK 11 Support
JDK 11 was the first Long Term Support (LTS) release of Java since the new release cycle had been introduced. This release included some great new features, which are fully supported in Apache NetBeans. JDK 11 has a number of new features, ranging from new String methods to the new HTTP client. Apache NetBeans contains full support for these features.
PHP
The life of a PHP developer can also be made easier by making use of the native debugger. One can set a breakpoint on a line of code and run the debugger, then the application will run and once the breakpoint is reached, the editor will be opened to the breakpoint, enabling the developer to debug variable values and states at that point in time.
All of these advancements in PHP support make Apache NetBeans one of the foremost IDEs for developing in PHP.
Apache NetBeans 11.0
The Apache NetBeans 11.0 release includes full support for Java EE and Gradle, as well as support for JDK 12 features.
JDK 12 Support
The Java release cadence is allowing for a new release of the JDK every six months. As such, the Apache NetBeans release cycle should allow the IDE to continue to include the support for the most recent JDK. That said, JDK 12 support has been added to Apache NetBeans 11.0, including a preview of switch expression support, and support for compact number formatting. This includes hints such as the “convert to rule switch” for the new switch support.
Java EE Support
Up through Apache NetBeans 10.0, if one wished to utilize Java EE features, the modules needed to be enabled via the Apache NetBeans 8.2 update center. This is because Java EE support was not yet part of the Apache NetBeans distribution. The full enterprise cluster has been transferred to become part of the Apache NetBeans distribution with Apache NetBeans 11.0. This means that out of the box, the Apache NetBeans distribution includes full support for Java EE, without the requirement to download and install any additional modules.
Not only does Apache NetBeans 11.0 include support for Java EE, but it also includes support for Jakarta EE 8 via the Java EE 8 support that has been added in Apache NetBeans 11.1. The new support allows one to create a new Maven-based Jakarta EE/Java EE project using Java EE 8. It also allows one to install Java EE 8-compliant application server containers and manage them via the IDE, such as GlassFish 5.1.
Gradle
Another feature that required enablement in previous Apache NetBeans releases was Gradle support. As part of Apache NetBeans 11.0, Gradle support has been made first-class, so it works out of the box. Gradle projects can now be opened out of the box, and a Gradle Task Navigator has been integrated, allowing one to run tasks using a double-click. This also allows one to make use of Gradle supported unit test frameworks, and make use of run, debug, and test … even with single methods.
Conclusion
The Apache NetBeans IDE continues to progress with each release, supporting newer releases of the JDK and adding enhancements to make the IDE more useful to a broader spectrum of developers. If you have any features that you would like to see added to Apache NetBeans, please join the community and contribute your ideas. Now you are ready to develop desktop applications.