Ioannis Kostaras, Constantin Drabo, Josh Juneau, Sven Reimers, Mario Schröder and Geertjan Wielenga

Pro Apache NetBeans

Building Applications on the Rich Client Platform

Ioannis Kostaras
The Hague, South Holland, The Netherlands
Constantin Drabo
Ouagadougou, Burkina Faso
Josh Juneau
Chicago, IL, USA
Sven Reimers
Salem, Germany
Mario Schröder
Berlin, Germany
Geertjan Wielenga
Amsterdam, The Netherlands
ISBN 978-1-4842-5369-4e-ISBN 978-1-4842-5370-0
© Ioannis Kostaras, Constantin Drabo, Josh Juneau, Sven Reimers, Mario Schröder, Geertjan Wielenga 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

Dedicated to our families who have silently supported us in our adventures as authors. More specifically:

Ioannis Kostaras:

To my lovely wife Katerina; my adorable little son Nikolaos-Ioannis; and my parents, Nikolaos and Zinovia

Constantin Drabo:

I dedicate this book to my lovely mother, my brother Emmanuel, and sister Denise, my spouse Mariam, and my little son Johann. Finally, to these special persons: Geertjan Wielenga and Malo Sadouanouan

Josh Juneau:

To my wife Angela; and my children, Katie, Jake, Matt, Zach, and Luke

Sven Reimers:

To my beloved wife Isabelle

Mario Schröder:

To my wife Fridah

Geertjan Wielenga:

To my wife Hermine

Introduction

Pro Apache NetBeans provides a detailed overview of the latest additions to NetBeans IDE, like support for JShell, the Jigsaw Module System, and Local Variable Type Inference, focusing on what this new version brings to developers. It also describes new features in NetBeans Platform, that is, the framework the NetBeans IDE has been built upon.

The book is a practical, hands-on guide providing a number of step-by-step recipes that help you take advantage of the power in the latest Java (and other) software platforms, and it gives a good grounding in using NetBeans IDE for your projects. This book has been written by the Apache community members who have been using the IDE and actively contributing and developing Apache NetBeans as an open source project.

Pro Apache NetBeans consists of three parts. The first part describes how to use the IDE as well as the new features that it brings to support the latest Java versions. The second part describes how you can extend NetBeans by creating plugins or writing your own standalone applications using the Rich Client Platform. The third part describes how you can contribute to develop your favorite IDE further, becoming part of the open source team that is driving future developments in the toolset.

In more detail, Chapter 1 , “What Is NetBeans,” provides a gentle introduction to NetBeans. It explains what NetBeans is and what it is not, its history, all the way to its new home, the Apache Software Foundation, being its second biggest project. It also provides an introduction of the many programming languages and tools that NetBeans supports, and it introduces you to many other things that are explained in more detail in the rest of the book.

Chapter 2 , “Getting Started with NetBeans,” provides an overview of the NetBeans IDE, which will help new users to become familiar with its User Interface, the various windows, and it introduces you to how to build your first Java project. It also provides useful tricks and tips to help you speed up your productivity.

Chapter 3 provides an overview of the new features that Apache NetBeans IDE, since version 9.0, provides for Java versions 9–12 and other programming languages. It describes support for JShell, the Jigsaw Module System, HttpClient and Local Variable Type Inference, as well as improvements for PHP.

Chapter 4 describes how to develop desktop applications. These are standalone applications running, typically, locally on your machine without the need of a web or an application server. The chapter explains there are three ways to develop Java GUI desktop applications: using the Abstract Window Toolkit (AWT), Swing, or JavaFX. NetBeans provides a very powerful visual editor that you can use to build your GUI with dragging and dropping components onto forms (panels). The chapter also guides you through the steps for developing your own desktop application.

Chapter 5 describes how to build Enterprise (or Web) applications. Contrary to desktop applications, these require a web or application server to serve HTML pages. Java EE support has been included with Apache NetBeans since release 11.0. Full support for Maven web applications and Java EE technologies such as Enterprise JavaBeans (EJB), Contexts and Dependency Injection (CDI), and JavaServer Faces (JSF) allows developers the convenience of auto-completion, code fragments, and easy syntax recognition. After finishing this chapter, you will have a basic understanding of the conveniences provided by Apache NetBeans for full stack Java EE development.

Chapter 6 , “Debugging and Profiling Applications,” explains in detail the powerful debugger and profiler of Apache NetBeans. If debugging makes your code right, profiling will make it run fast. Things like breakpoints, debugging multi-threaded code, CPU and memory profiling, snapshots, etc., are explained in this chapter.

Part II of the book describes the NetBeans Platform (or Rich Client Platform), that is, the framework or libraries that the NetBeans IDE has been built upon. With this knowledge you can better understand the NetBeans source code that will allow you to fix bugs, or extend it by writing your own plugins. Or you can use it to develop your own desktop applications faster than using Swing.

Chapter 7 , “Mastering the Core Platform,” introduces the reader to the core APIs of the NetBeans Platform, namely, the NetBeans module system, the FileSystem, and the Lookups. NetBeans provides its own module system to modularize applications, which supports the use of OSGi. A comparison with Java’s module system, Jigsaw, is provided in this chapter. NetBeans also provides its own libraries to access the filesystem. A comparison with NIO.2, introduced in Java 7, is provided. Finally, the Lookups are a very powerful tool to build loosely coupled applications. A comparison with Java 6ServiceLoader is also provided.

Chapter 8 , “Mastering the User Interface,” teaches the reader the GUI components of the NetBeans Platform, namely the Window system, the Action system, the Node System, and the Explorer Views and Property Sheets, all reducing the time you need to develop powerful UIs.

In Chapter 9 , the reader applies what s/he has learned so far by porting a desktop application to NetBeans RCP. The development is done in three steps: (1) Build a “static” visual prototype of the user interface; (2) Build a “dynamic” prototype of the application, coding user interface events and associated business logic and creating customized UI components as needed; and (3) Code the persistence logic.

Chapter 10 , “Learning the Extras of the Platform,” describes many of the other APIs provided by the NetBeans Platform, such as the Dialogs API, the Visual Library and the Palette, the Status Bar and Notifications, the progress bar, the QuickSearch and the Output window, etc.

Chapter 11 teaches you how to extend NetBeans by writing a plugin for it. You will learn step by step how to develop a plugin for Hyperledger, an open source effort to advance blockchain technologies, hosted by the Linux Foundation.

Part III gives you an overview of the new home that hosts NetBeans, the Apache Foundation; its infrastructure to support open source projects like the various tools that allow issue tracking, testing, documentation, etc.; and gives you all the information you need to become a contributor of Apache NetBeans.

Chapter 12 describes the Apache NetBeans Process. After a short history, it explains how the migration of source code was achieved from Oracle to Apache, the various NetBeans versions under Apache as an incubator project, and the graduation to a top-level Apache Project.

Chapter 13 describes the Apache Infrastructure and the various tools that the Apache Software Foundation provides for its projects for issue/bug reporting, wikis, websites, etc.

Chapter 14 describes the NetCAT program. TheNet Beans IDEC ommunityA cceptanceT esting program is very important for the quality of the product. A typical NetCAT program takes around two months of activities. The chapter explains how each NetBeans version is tested by the community before it is released. You can easily participate in this program and execute tests, thus helping to improve your favorite IDE.

Chapter 15 , provides an overview of the NetBeans source code, its architecture, its various modules, and their dependencies. It describes how to download and build the NetBeans source code, load it in NetBeans IDE, and debug it. Finally, this chapter encourages you to contribute to the NetBeans source code by fixing bugs and committing your changes to a baseline.

Acknowledgments

Authoring a book is like departing for an adventure. Even though you make a plan, you don’t know how long it is going to take, how big the waves will be, and what new land you are going to explore. Like Odysseus, we seek our Ithaca and the way is not always easy – it is full of adventures and exciting indeed – but rewarding in the end.

This book is our adventure into an IDE we all love and continue to work with. So before anybody else, we would like to acknowledge and thank this little team from the University of Prague who had the fancy idea of creating NetBeans, its never-tired Product Manager, Geertjan Wielenga, as well as all the people that have contributed one way or another, all these years, to make this IDE a necessity for all of us.

We would also like to thank the Apress team for their patience and support in a multi-author community book that has not always been easy to manage and coordinate, their persistent comments leaving nothing to chance, and scrutinizing every sentence of the drafts. However, any errors that may still exist are the responsibility of the authors.

Finally, but not least, we would like to thank our families for bearing with us during our adventure, when we were spending many hours behind a computer’s screen, trying to explain as best as we could the many NetBeans topics you will find in this book, as well as writing example programs that would give more value to its readers.

Table of Contents

Part I: Using Apache NetBeans1
Part II: Extending Apache NetBeans179
Index 457

About the Authors and About the Technical Reviewer

About the Authors

Ioannis (John) Kostaras
../images/479166_1_En_BookFrontmatter_Figb_HTML.jpg

graduated from the Informatics Department at the University of Athens. He also holds a Master of Science degree in Telecommunications and Information Systems from the Electronics Systems Engineering Department of Essex University, and a Master of Arts degree in Management Studies also from Essex University. Ioannis is a software architect/senior software engineer in an international organization located in The Hague, Netherlands, developing real-time critical distributed systems, and has been a Java developer since JDK 1.0 was released. One of the many applications he has written for the industry, developed in the NetBeans Rich Client Platform, was awarded the 2012 Duke’s Choice Award. He is also a member of the NetBeans Dream Team and an Apache NetBeans contributor. Apart from Java, he “speaks” other languages, such as C/C++, Python, Ruby, and Erlang, to name a few; and he codes them using his favorite IDE, NetBeans. He has written a number of articles in JavaCodeGeeks, and in the NetBeans wiki, and runs an online course for Java in Greek in the Mathesis platform, teaching the latest Java and Apache NetBeans to audiences speaking Greek. Finally, but not least, he is a co-organizer of JCrete, the hottest Java unconference, on the island of Crete.

 
Constantin Drabo
../images/479166_1_En_BookFrontmatter_Figc_HTML.jpg

earned a Master’s Degree from the Université de Picardie Jules Verne (France) in Internet Technologies. He is a software engineer in the National Treasury of Burkina Faso, and is a part-time teacher at the Université Nazi Boni of Bobo-Dioulasso, where he teaches on Java/Java EE and the Human/Machine Interface. He participates in the Java Community Process (JCP) through his contribution to JSR 381 (Visual Recognition). Constantin is a member of the NetBeans Dream Team, and creator of the FasoJUG Java User Group. He is currently studying for his PhD in Machine Learning in Medical Systems.

 
Josh Juneau
../images/479166_1_En_BookFrontmatter_Figd_HTML.jpg

has been developing software and database systems for several years. Database application development and sophisticated web apps have been the focus of his career since the beginning. Early in his career, he became an Oracle database administrator and adopted the PL/SQL language for performing administrative tasks and developing applications for the Oracle database. In an effort to build more complex solutions, he began to incorporate Java into his PL/SQL applications, and later developed standalone and web applications with Java. Josh wrote his early Java web applications utilizing JDBC to work with back-end databases. Later, he incorporated frameworks into his enterprise solutions, including Java EE, Spring, and JBoss Seam. Today, he primarily develops enterprise web solutions utilizing Java EE. He is an avid contributor to Oracle’sJava Magazine , speaks at conferences and Java user group events, contributes to the Chicago Java User Group, and is an Apache NetBeans committer and a Java Champion.

 
Sven Reimers
../images/479166_1_En_BookFrontmatter_Fige_HTML.jpg

is based at Lake Constance in Southern Germany where he works as a systems engineer for Airbus Defence and Space creating next-generation ground segment software for space systems. He has more than 20 years’ experience building complex distributed software systems, and more than 20 years’ experience with Java. In 2009, Reimers was the winner of the Duke’s Choice Award in the Network Solutions category for ND SatCom’s Satellite Communication Management Software. He is part of the Apache NetBeans PMC, an author at OpenJFX, a regular speaker at conferences, as well as leader and founder of JUG Bodensee. For his long-term commitment to Java, the Java community, and his contributions to the Java ecosystem, Reimers was named a Java Champion in 2014.

 
Mario Schröder
../images/479166_1_En_BookFrontmatter_Figf_HTML.jpg

earned a Master’s Degree in Civil Engineering from the University of Rostock in Germany. However, he discovered his passion for computer science during his studies and made programming and software development into his profession. He started working with Java professionally in 2001. He is a certified Java Programmer, iSAQB-Software Architect, and ISTQB-Tester. His first contact with NetBeans was in 2004. He was a member of the NetCat team for Version 7.2, has contributed patches to the platform, and has developed several plugins.

 
Geertjan Wielenga
../images/479166_1_En_BookFrontmatter_Figg_HTML.jpg

is the Apache NetBeans PMC Chair and a product manager at Oracle for Oracle JET, which is Oracle’s free and open source front-end JavaScript technology stack. He lives and works in Amsterdam. He is a Java and JavaScript technology enthusiast, advocate, trainer, speaker, and writer. He studied law at the University of Natal in Pietermaritzburg, South Africa. In early 1996, he started working as a technical writer for a software technology organization in the Netherlands and, after having worked at various other software organizations in the Netherlands, he moved to Vienna, Austria, and worked as a technical writer for the documentation of Coca-Cola’s ERP system. In 2004, he moved to Prague, Czech Republic, to work on NetBeans IDE, again as a technical writer. He discovered that NetBeans IDE is a unique product, project, and ecosystem and became inspired and continually enthused by the open source ecosystem around NetBeans IDE, the technologies around it, and the central role that the NetBeans community plays in them. He is happy and proud of the role NetBeans IDE has played in its many years of existence and its continued development in the Apache Software Foundation.

 

About the Technical Reviewer

Kevin Farnham
../images/479166_1_En_BookFrontmatter_Figh_HTML.jpg

has developed software for high-volume data analysis and mathematical modeling since the 1980s. He has been site editor and lead blogger for technology websites at Oracle, Intel, and O’Reilly Media.

Kevin has served as technical editor and reviewer for dozens of software engineering books.

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

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