© Ioannis Kostaras, Constantin Drabo, Josh Juneau, Sven Reimers, Mario Schröder, Geertjan Wielenga 2020
I. Kostaras et al.Pro Apache NetBeanshttps://doi.org/10.1007/978-1-4842-5370-0_3

3. Apache NetBeans: New Features

Ioannis Kostaras1 , Constantin Drabo2, Josh Juneau3, Sven Reimers4, Mario Schröder5 and Geertjan Wielenga6
(1)
The Hague, South Holland, The Netherlands
(2)
Ouagadougou, Burkina Faso
(3)
Chicago, IL, USA
(4)
Salem, Germany
(5)
Berlin, Germany
(6)
Amsterdam, The Netherlands
 

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 ToolsOpen 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.

Once in the JShell editor, the utility can be used just as it is from the command line. That is, one can execute Java statements or blocks without enclosing them into a Java class. Moreover, Java code can be executed without compilation. This makes the JShell editor perfect for performing testing. See Figure 3-1.
../images/479166_1_En_3_Chapter/479166_1_En_3_Fig1_HTML.jpg
Figure 3-1

Apache NetBeans JShell Editor

Utilizing JShell from within Apache NetBeans has some great benefits. When working within the editor, one can test code and then press the Save to Class button to save the code into a Java class with one click. JShell can also be configured into Ant-based Java SE applications as an agent, allowing JShell to be invoked by the application. The preferences pane of Apache NetBeans includes options for configuring JShell history, auto-open the JShell, and modifying the JDK used for JShell. See Figure 3-2.
../images/479166_1_En_3_Chapter/479166_1_En_3_Fig2_HTML.jpg
Figure 3-2

JShell Support

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.

Taking a look at the new Java String method support, the IDE will auto-complete the newly added methods. In the screenshot below (Figure 3-3), you can see the new repeat() functionality.
../images/479166_1_En_3_Chapter/479166_1_En_3_Fig3_HTML.jpg
Figure 3-3

JDK 12 Support

The IDE also has complete support for the new HTTP client. As the next screenshot demonstrates (Figure 3-4), the HttpClient can be utilized within a Java SE class, and the IDE includes full auto-complete support while coding.
../images/479166_1_En_3_Chapter/479166_1_En_3_Fig4_HTML.jpg
Figure 3-4

HttpClient Support

PHP

The Apache NetBeans IDE contains full support for PHP 7.0, 7.1, 7.2, and 7.3. This enables one to create a new PHP project using some of the latest PHP advances. PHP has been a part of Apache NetBeans for years, but only up through PHP 7.0 was it supported without installing additional plugins. Since Apache NetBeans 10.0, PHP has become a part of the standard distribution. See Figure 3-5.
../images/479166_1_En_3_Chapter/479166_1_En_3_Fig5_HTML.jpg
Figure 3-5

PHP New Project Dialog

The Apache NetBeans editor supports such features as the "void" type in PHP, as well as any of the other PHP enhancements through PHP 7.3. For instance, there is support for allowing a trailing comma in function calls. This may help in the case where a comma is accidentally forgotten or perhaps a list may continue to grow at some point. See Figure 3-6.
../images/479166_1_En_3_Chapter/479166_1_En_3_Fig6_HTML.jpg
Figure 3-6

Trailing Comma Support

Another newer feature of PHP is support for multi-catch exception handling, and the Apache NetBeans environment allows support for this feature as well (Figure 3-7).
../images/479166_1_En_3_Chapter/479166_1_En_3_Fig7_HTML.jpg
Figure 3-7

PHP Multi-Catch Exception Handling

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.171.121