Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Mastering NetBeans
Mastering NetBeans
Mastering NetBeans
Ebook572 pages8 hours

Mastering NetBeans

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Master building complex applications with NetBeans to become more proficient programmers

About This Book
  • Customize NetBeans to fit your unique needs
  • Excel in NetBeans IDE, learning the shortcuts and hidden features to become more productive
  • A comprehensive guide to become more productive at application development using NetBeans IDE
Who This Book Is For

If you are a competent developer who wants to fast-track your application development with NetBeans IDE, then this book is for you. Reasonable knowledge and an understanding of Java programming and NetBeans IDE is assumed.

What You Will Learn
  • Install NetBeans either from a distribution package or from source code
  • Test, debug, and run production code using the NetBeans IDE
  • Use external services such as PaaS environments and web services
  • Create desktop applications using Swing tools
  • Manage and configure relational databases
  • Build a Java business model and web tiers using Java EE and Spring technologies
  • Explore web services both with XML and RESTful approaches
  • Handle external services such as databases , Maven repositories, and cloud providers
  • Extend NetBeans for those situations where you require more from your IDE
In Detail

With the increasing complexity of software development and the abundance of tools available, learning your IDE in-depth will instantly increase your developer productivity. NetBeans is the only IDE that can be downloaded with Java itself and provides you with many cutting edge features not readily available with many IDEs. The IDE also provides a great set of tools for PHP and C/C++ developers. It is free and open source and has a large community of users and developers around the world.

This book will teach you to ace NetBeans IDE and make use of it in creating Java business and web services. It will help you to become a proficient developer and use NetBeans for software development. You will learn effective third-party interaction and enable yourself for productive database development.

Moving on, you will see how to create EJB projects and write effective and efficient web applications. Then you will learn how to use Swing and manage and configure a relational database. By the end of the book, you will be able to handle external services such as databases, Maven repositories, and cloud providers, and extend your NetBeans when you require more from your IDE.

Style and approach

An easy-to-follow yet comprehensive guide to help you master the exhaustive range of NetBeans features in order to become more efficient at Java programing. More advanced topics are covered in each chapter, with subjects grouped according to their complexity as well as their utility.

LanguageEnglish
Release dateAug 28, 2015
ISBN9781785286896
Mastering NetBeans
Author

David Salter

David Salter is a veteran independent journalist, author and television producer. He was Executive Producer of Media Watch and Editor-in-Chief of The Week. He has written books on Australian history, sport, and the media and is himself an experienced offshore racing sailor.

Related to Mastering NetBeans

Related ebooks

Programming For You

View More

Related articles

Reviews for Mastering NetBeans

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Mastering NetBeans - David Salter

    Table of Contents

    Mastering NetBeans

    Credits

    About the Author

    About the Reviewers

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    Why subscribe?

    Free access for Packt account holders

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Downloading the example code

    Downloading the color images of this book

    Errata

    Piracy

    Questions

    1. Getting Started with NetBeans

    Choosing a download bundle of NetBeans

    Downloading and installing NetBeans

    Installing other versions of NetBeans

    NetBeans user directory

    Updating NetBeans to the latest version

    Obtaining the NetBeans source code

    Downloading a zipped archive of the NetBeans source code

    Cloning the NetBeans source code from Mercurial

    Cloning specific versions of NetBeans

    Cloning the NetBeans source code from within NetBeans

    Browsing the NetBeans source code online

    Building NetBeans

    Building NetBeans via the command line

    Building NetBeans from within NetBeans

    NetBeans configuration

    User and cache directories

    NetBeans default options

    NetBeans JDK

    Additional module clusters

    Further options

    Summary

    2. Editing Files and Projects

    The NetBeans screen layout

    The explorer style windows

    The Favorites window

    The Navigator window

    The source code editor window

    The History view

    The Palette window

    The Properties window

    The Output window

    Window management

    Specifying default templates for files

    Code templates and code snippets

    Inserting code using code templates

    Code snippets – the NetBeans Palette window

    Deleting palette items – the Palette Manager

    Editing palette items

    Macro recording and playback

    Assigning shortcuts for macro playback

    Recording new macros

    Splitting windows

    Code folds

    Project groups

    Summary

    3. The NetBeans Developer's Life Cycle

    Running applications

    Debugging applications

    Breakpoints

    The Variables debug window

    The Watches window

    Evaluating expressions

    The Call Stack window

    The Loaded Classes window

    The Sessions window

    The Threads window

    The Sources window

    The Debugging window

    Deadlock detection

    Analyze Stack Window

    Variable formatters

    Debugging remote applications

    Profiling applications

    Application monitoring

    Performance monitoring

    Memory monitoring

    Testing applications

    Code coverage

    Performing TDD within NetBeans

    Summary

    4. Managing Services

    Databases

    Connecting to Java DB

    Connecting to MySQL

    Connecting to other databases via JDBC

    Managing databases

    Web Services

    Application Servers

    Maven Repositories

    Cloud services

    Hudson Builders

    Task Repositories

    Summary

    5. Database Persistence

    Java EE Persistence

    JPA entities

    Creating blank entity classes

    Editing the persistence.xml file

    Creating entity classes from databases

    Creating JPA controllers for entities

    Creating database scripts from entity classes

    Summary

    6. Desktop Development

    Java Swing applications

    Creating Swing frames

    Designing Swing forms

    Anchoring and autoresizing components

    Defining properties and events

    Editing properties

    Editing bindings

    Advanced binding properties

    Converters

    Validators

    Editing events

    Editing code

    Creating connections

    JavaFX applications

    JavaFX Scene Builder

    Summary

    7. Creating the Business Layer

    Creating enterprise projects

    Creating a NetBeans multi-module project

    A Maven multi-module project

    Creating a Maven multi-module project

    Creating EJBs

    Creating a session bean façade for entity classes

    The Java Bean Validation framework

    Creating a Bean Validation constraint

    Contexts and Dependency Injection

    Adding CDI support

    CDI injection points editor support

    Summary

    8. Creating the Web Tier

    Creating web projects

    Configuring application servers

    Creating a web application

    Creating a NetBeans web application

    Modifying a NetBeans web application

    Creating a Maven web application

    The web project's Run options

    Adding components to a web application

    Creating Spring web applications

    Changing the version of Spring used

    Spring application development shortcuts

    Modern Spring development

    Enhancing Spring Boot support

    CSS preprocessors

    Configuring Less and SASS in NetBeans

    Configuring Less and Sass on a project basis

    Creating CSS rules

    Adding JavaScript to a web application

    Checking JavaScript files

    Summary

    9. Creating and Consuming Web Services

    Creating web services

    Creating a SOAP web service

    Creating a SOAP web service from scratch

    Creating a SOAP web service from WSDL

    Managing SOAP-based web services

    Testing web services

    Message handlers

    Managing web services graphically

    Consuming SOAP web services

    Creating RESTful web services

    The Simple Root Resource option

    The Container-Item option

    The Client-Controlled Container-Item option

    Summary

    10. Extending NetBeans

    Creating NetBeans plugins

    NetBeans rich client platform applications

    Creating a NetBeans RCP application

    Branding the application

    Application properties

    Creating platform application components

    Creating a NetBeans window

    Summary

    Index

    Mastering NetBeans


    Mastering NetBeans

    Copyright © 2015 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: August 2015

    Production reference: 1250815

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-78528-264-5

    www.packtpub.com

    Credits

    Author

    David Salter

    Reviewers

    Michel Graciano

    Halil Karaköse

    Mario Pérez Madueño

    Commissioning Editor

    Nadeem Bagban

    Acquisition Editor

    Larissa Pinto

    Content Development Editor

    Anand Singh

    Technical Editor

    Ankita Thakur

    Copy Editor

    Swati Priya

    Project Coordinator

    Vijay Kushlani

    Proofreader

    Safis Editing

    Indexer

    Monica Ajmera Mehta

    Production Coordinator

    Arvindkumar Gupta

    Cover Work

    Arvindkumar Gupta

    About the Author

    David Salter is an enterprise software developer and architect who has been developing software professionally since 1991. His relationship with Java goes right back to the beginning, when he used Java 1.0 to write desktop applications and applets for interactive websites. He has been developing enterprise Java applications using both Java EE (and J2EE) and open source solutions since 2001. He has also written NetBeans IDE 8 Cookbook and Seam 2.x Web Development and coauthored Building SOA-Based Composite Applications Using NetBeans IDE 6, all by Packt Publishing.

    First and foremost, I would like to thank my wife and family for putting up with my many hours at the computer while writing this book. Special thanks and love to my wife for all her encouragement and support.

    I'd also like to say thanks to all the people at Packt Publishing for helping me with this book. Thank you, Larissa, for your encouragement from the beginning. I would also like to thank Anand and Ankita for their hard work in helping me complete this book.

    Finally, thanks to everyone who has worked on NetBeans, making it the product it is today. Without you all, this book would not exist.

    About the Reviewers

    Michel Graciano is highly familiar with development techniques, such as object- and component-oriented programming, design patterns' applicability, and software analysis. An expert in application development with open source software, he is currently working as an instructor at Código Efetivo, a training company in Brazil.

    He is actively involved with open source projects, such as NetBeans, and has delivered talks at JustJava, The Developer's Conference, and JavaOne conferences.

    His longtime contributions to NetBeans started with the Portuguese translation project and continued through his participation in the NetFIX and NetCAT programs, leading to him becoming a NetBeans Dream Team member.

    I would like to thank my wife for all her encouragement and support, in this and the other projects I get involved in.

    Halil Karaköse is a freelance software architect who graduated from Işik University Computer Engineering Department in 2005.

    He worked in the telecommunications industry as a software developer and software architect for 10 years, including companies such as Turkcell and Ericsson. In 2014, he quit Ericsson to establish his own software consultancy company, kodfarki.com.

    He has keen interest in Java tools, which speed up development, such as NetBeans and Intellij IDEA. He loves mouseless driven development.

    Mario Pérez Madueño graduated in computer engineering from the Open University of Catalonia (UOC), Spain, in 2010. He is an early adopter of Java tech and advocates agile development methodologies. He has been a member of the NetBeans Community Acceptance Testing (NetCAT) program for many years. He has also contributed as a technical reviewer to Building SOA-Based Composite Applications Using NetBeans IDE 6 and Java EE 7 Development with NetBeans 8, both by Packt Publishing.

    I would like to thank my wife, María, for her unconditional help and support in all the projects I get involved in. I would also like to thank Martín and Matías for giving me the strength to go ahead.

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    For support files and downloads related to your book, please visit www.PacktPub.com.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

    https://www2.packtpub.com/books/subscription/packtlib

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print, and bookmark content

    On demand and accessible via a web browser

    Free access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

    Preface

    NetBeans is the only IDE that can be downloaded with Java itself. It provides developers with many cutting-edge features that are not available with all the other IDEs.

    This book will teach you how to master the NetBeans IDE. You will learn how to utilize and master the NetBeans IDE to become a proficient developer.

    This book is packed with many hints, tips, and time-saving techniques. Reading this book will teach you about the features provided by NetBeans that newcomers to the IDE are not aware of and experienced programmers make extensive use of on a day-to-day basis.

    What this book covers

    Chapter 1, Getting Started with NetBeans, describes the different versions of NetBeans that are available to download and shows you how to install NetBeans from an installable package or from the source code.

    Chapter 2, Editing Files and Projects, teaches you about the many different facilities available while editing files. You will learn about macros, project groups, the NetBeans windowing system, and much more.

    Chapter 3, The NetBeans Developer's Life Cycle, explains how NetBeans helps with the tasks that every developer does on a daily basis—running, debugging, testing, and profiling applications.

    Chapter 4, Managing Services, shows you how NetBeans manages external services such as Maven repositories, PaaS, and continuous integration systems.

    Chapter 5, Database Persistence, describes the features that NetBeans provides to help write database applications, from both a code-first and data-first perspective.

    Chapter 6, Desktop Development, describes the excellent features provided by NetBeans for developing desktop Swing applications.

    Chapter 7, Creating the Business Layer, teaches you the tools provided to help developers write the business layers of applications, describing subjects such as EJBs and bean validation.

    Chapter 8, Creating the Web Tier, explains the different features available for Java web developers, including details of creating Spring web applications and using CSS preprocessors.

    Chapter 9, Creating and Consuming Web Services, explains how NetBeans makes it straightforward to create and consume both RESTful and SOAP-based web services.

    Chapter 10, Extending NetBeans, describes how to create NetBeans plugins for those situations where you need to customize the IDE along with the details of how to start using NetBeans as the platform for desktop applications.

    What you need for this book

    To use this book, you need to download and install the NetBeans IDE on either Windows, Mac OS X, or Linux.

    You also need to have a modern version of Java (preferably, Java 8). To benefit the most when learning about web services and EJB-related technologies, a Java EE application server is required. The enterprise download bundle of NetBeans is supplied with full support for GlassFish 4 Open Source edition.

    Who this book is for

    This book is written for Java developers of all the levels who want to gain more knowledge about how their IDE works and learn new techniques to enable them to become more productive when using NetBeans.

    A reasonable level of Java and Java EE knowledge is assumed.

    Conventions

    In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

    Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: From there, double-click on the included NetBeans xxx.mpkg file to start the installation (the exact names of the .dmg and .mpkg files varies, depending upon the version and bundle downloaded).

    A block of code is set as follows:

    public class Main {

        public static void main(String args[]) {

            Greeter greeter = new Greeter();

           

            System.out.println(greeter.greet(David));

        }

    }

    When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

    <#assign licenseFirst = /*>

    <#assign licensePrefix = * >

    <#assign licenseLast = */>

    <#include ${project.licensePath}>

     

    <#if package?? && package != >

    package ${package};

     

    /**

    * Project: ${project.name} * ${url}

     

    *

    * @author ${user}

    */

    public class ${name} {

     

    }

    Any command-line input or output is written as follows:

    chmod +x netbeans--linux.sh

    New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: From here, we can customize NetBeans by clicking on the Customize button.

    Note

    Warnings or important notes appear in a box like this.

    Tip

    Tips and tricks appear like this.

    Reader feedback

    Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

    To send us general feedback, simply e-mail <feedback@packtpub.com>, and mention the book's title in the subject of your message.

    If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

    Customer support

    Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

    Downloading the example code

    You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

    Downloading the color images of this book

    We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: https://www.packtpub.com/sites/default/files/downloads/2645OS_ColorImages.pdf.

    Errata

    Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

    To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

    Piracy

    Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

    Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.

    We appreciate your help in protecting our authors and our ability to bring you valuable content.

    Questions

    If you have a problem with any aspect of this book, you can contact us at <questions@packtpub.com>, and we will do our best to address the problem.

    Chapter 1. Getting Started with NetBeans

    NetBeans IDE 8 is the official IDE for Java 8, and the only IDE that can be downloaded with official distributions of Java 8.

    The latest version, NetBeans IDE 8.0.2, provides tools to allow developers to create desktop, mobile, and web applications using all of the latest Java specifications such as Java SE 8, Java ME 8, and Java EE 7.

    This chapter will cover the following topics:

    Choosing a download bundle of NetBeans

    Downloading and installing NetBeans

    Updating NetBeans to the latest version

    Downloading NetBeans source code from Mercurial

    Building NetBeans

    NetBeans configuration

    Choosing a download bundle of NetBeans

    There are three different installation bundles of NetBeans (which can be downloaded from the NetBeans site) that are relevant to Java developers:

    Java SE

    Java EE

    All

    In addition to these three bundles, C/C++ and HTML5 & PHP bundles are also available for download. These bundles are not targeted at Java developers though, so they will not be discussed further in this book.

    The Java SE bundle provides the standard NetBeans Platform SDK along with support for Java SE and Java FX developers.

    The Java EE bundle contains everything that the SE bundle includes, but adds support for Java EE and HTML5 developers. GlassFish Server Open Source Edition 4.1 and Apache Tomcat 8.0.15 are also included with the Java EE bundle.

    The All bundle contains everything that the EE bundle includes, but adds support for C/C++, Groovy, and PHP developers.

    Downloading and installing NetBeans

    Downloading an installation of NetBeans (Java SE, Java EE, or All) is achieved by selecting the bundle to download and then clicking on the Download button for that bundle, as shown in the preceding screenshot.

    All of the examples and screenshots in this book have been created with the Java EE bundle of NetBeans. It is recommended that you use the Java EE download bundle of NetBeans to adhere as closely as possible to the examples in this book.

    Note

    To install any version of NetBeans 8, the Java JDK Version 7 Update 10 or later, or Java JDK 8 or later, is required. These can be downloaded, if not already installed on your target system, from http://www.oracle.com/technetwork/java/javase/downloads.

    Having downloaded the appropriate NetBeans bundle installer for your operating system, you can install NetBeans on your development system. The installation procedure differs slightly for the three main operating systems NetBeans is available for.

    For Windows, simply launch the NetBeans installer by double-clicking on the file, netbeans--windows.exe (the exact filename differs depending upon the version and bundle downloaded).

    For Mac OS X, double-click on the downloaded file, netbeans--macosx.dmg, to mount the installation device. From there, double-click on the included NetBeans xxx.mpkg file to start the installation (the exact names of the .dmg and .mpkg files vary, depending upon the version and bundle downloaded).

    For Linux, NetBeans is installed via a command-line script, so first we must change the permissions of the downloaded file to be executable. From a terminal window, execute the following command:

    chmod +x netbeans--linux.sh

    Tip

    Downloading the example code

    You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. You can also download the code samples from https://github.com/doobrie/masteringnb.

    To continue with the installation on Linux, we must now execute the downloaded

    Enjoying the preview?
    Page 1 of 1