Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Java EE 5 Development with NetBeans 6
Java EE 5 Development with NetBeans 6

Java EE 5 Development with NetBeans 6: Develop professional enterprise Java EE applications quickly and easily with this popular IDE

eBook
Can$47.69 Can$52.99
Paperback
Can$65.99
eBook + Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Java EE 5 Development with NetBeans 6

Chapter 1. Getting Started with NetBeans

In this chapter, we will cover how to get started with NetBeans, topics covered in this chapter include:

  • Introduction

  • Downloading NetBeans

  • Installing NetBeans

  • Starting NetBeans for the first time

  • Configuring NetBeans for Java EE development

  • Deploying our first application

  • NetBeans tips for effective development

Introduction

NetBeans is an Integrated Development Environment (IDE) and platform. Although initially the NetBeans IDE could only be used to develop Java applications, as of version 6 NetBeans supports several programming languages, either by built-in support or by installing additional plugins. Programming languages natively supported by NetBeans include Java, C, C++, Ruby, PHP, and Groovy. Developers can use NetBeans' API's to create both NetBeans plugins and standalone applications, taking advantage of NetBeans as a platform.

The NetBeans IDE supports several programming languages, but because of its roots as Java-only IDE, it is a lot more popular with Java language. As a Java IDE, NetBeans has built-in support for Java SE (Standard Edition) applications, which typically run in the user's desktop or notebook computer; Java ME (Micro Edition), which typically run in small devices such as cell phones or PDAs; and for Java EE (Enterprise Edition) applications, which typically run on "big iron" servers and can support thousands of concurrent users.

In this book, we will be focusing on the Java EE development capabilities of NetBeans, and how to take advantage of NetBeans features to help us develop Java EE applications more efficiently.

Some of the features we will cover include how NetBeans can help us speed up web applications using the Servlet API and JSPs by providing a starting point for these kind of artifacts, and how we can use the NetBeans palette to drag-and-drop code snippets into our JSPs, including HTML and JSP markup. We will also see how NetBeans can help us generate JPA entities from an existing database schema (JPA is the Java Persistence API, the standard Object-Relational mapping tool included with Java EE). We will see how NetBeans allows us to visually create web applications using the JavaServer Faces framework via its visual web development tool.

In addition to web development, we will also see how NetBeans allows us to add business methods to a stateless or stateful session bean in one shot, without having to add the method both to the bean and to its business interface, and how to easily develop web services. We will also cover how to easily write both EJB and web service clients by taking advantage of some very nice NetBeans features.

Before taking advantage of all of the above NetBeans features, we of course need to have NetBeans installed, as covered in the next section.

Chapter 1. Getting Started with NetBeans

In this chapter, we will cover how to get started with NetBeans, topics covered in this chapter include:

  • Introduction
  • Downloading NetBeans
  • Installing NetBeans
  • Starting NetBeans for the first time
  • Configuring NetBeans for Java EE development
  • Deploying our first application
  • NetBeans tips for effective development

Introduction

NetBeans is an Integrated Development Environment (IDE) and platform. Although initially the NetBeans IDE could only be used to develop Java applications, as of version 6 NetBeans supports several programming languages, either by built-in support or by installing additional plugins. Programming languages natively supported by NetBeans include Java, C, C++, Ruby, PHP, and Groovy. Developers can use NetBeans' API's to create both NetBeans plugins and standalone applications, taking advantage of NetBeans as a platform.

The NetBeans IDE supports several programming languages, but because of its roots as Java-only IDE, it is a lot more popular with Java language. As a Java IDE, NetBeans has built-in support for Java SE (Standard Edition) applications, which typically run in the user's desktop or notebook computer; Java ME (Micro Edition), which typically run in small devices such as cell phones or PDAs; and for Java EE (Enterprise Edition) applications, which typically run on "big iron" servers and can support thousands of concurrent users.

In this book, we will be focusing on the Java EE development capabilities of NetBeans, and how to take advantage of NetBeans features to help us develop Java EE applications more efficiently.

Some of the features we will cover include how NetBeans can help us speed up web applications using the Servlet API and JSPs by providing a starting point for these kind of artifacts, and how we can use the NetBeans palette to drag-and-drop code snippets into our JSPs, including HTML and JSP markup. We will also see how NetBeans can help us generate JPA entities from an existing database schema (JPA is the Java Persistence API, the standard Object-Relational mapping tool included with Java EE). We will see how NetBeans allows us to visually create web applications using the JavaServer Faces framework via its visual web development tool.

In addition to web development, we will also see how NetBeans allows us to add business methods to a stateless or stateful session bean in one shot, without having to add the method both to the bean and to its business interface, and how to easily develop web services. We will also cover how to easily write both EJB and web service clients by taking advantage of some very nice NetBeans features.

Before taking advantage of all of the above NetBeans features, we of course need to have NetBeans installed, as covered in the next section.

Downloading NetBeans

NetBeans can be downloaded from http://www.netbeans.org.

Downloading NetBeans

At the time of writing, NetBeans 6.5 is in beta, by publication time it should be the current version. To download NetBeans we need to click on the button labeled Download NetBeans IDE.Clicking on this button will take us to a page displaying all of NetBeans download bundles.

Downloading NetBeans

NetBeans download bundles contain different NetBeans Packs that provide different levels of functionality. The following table summarizes the different available NetBeans packs and describes the functionality they provide.

Note

These packs can also be installed at a later date into an existing NetBeans installation by installing the appropriate plugins.

NetBeans Pack

Description

Java

Includes features for development of Java Standard Edition applications, as well as web and Java Enterprise Edition and mobile applications.

Ruby

Includes features for development of applications written in the Ruby language.

C/C++

Includes features for development of applications written in the C or C++ languages.

PHP

Includes features for development of PHP applications.

All

Includes functionality of all NetBeans packs.

To follow the examples in this book, either the Java or the All Pack is needed.

Note

The screenshots in this book were taken with the All Pack. NetBeans may look slightly different if the Java Pack is used, particularly, some menu items might be missing.

The following platforms are officially supported:

  • Windows 2000/XP/Vista
  • Linux x86
  • Linux x64
  • Solaris x86
  • Solaris x64
  • Mac OS X

Additionally, NetBeans can be used under any platform containing JDK 5.0 or newer. To download a version of NetBeans to be used under one of these platforms, an OS independent version of NetBeans is available for download.

Note

Although the OS-independent version of NetBeans can be executed in all of the supported platforms, it is recommended to obtain the platform-specific version of NetBeans for your platform.

The NetBeans download page should detect the operating system being used to access it, and the appropriate platform should be selected by default. If this is not the case, or if you are downloading NetBeans with the intention of installing it in another workstation on another platform, the correct platform can be selected from the drop-down labeled, appropriately enough, Platform.

Once the correct platform has been selected, we need to click on the appropriate download button for the NetBeans pack we wish to install; for Java EE development, we need either the Java or the All Pack. NetBeans will then be downloaded to a directory of our choosing.

Note

Java EE applications need to be deployed to an application server. Several application servers exist in the market, both the Java and the All NetBeans Packs come with GlassFish bundled. GlassFish is a 100 percent Java EE compliant application server. We will be using the bundled GlassFish application server to deploy and execute our examples.

Installing NetBeans

NetBeans requires a Java Development Kit (JDK) version 5.0 or newer to be available before it can be installed.

Note

Since this book is aimed at experienced Java Developers, we will not spend much time explaining how to install and configure the JDK, since we can safely assume the target market for the book more than likely has a JDK installed. Installation instructions for JDK 6 Update 3 (the latest at the time of writing) can be found at http://java.sun.com/javase/6/webnotes/install/index.html.

Readers wishing to use Mac OS X can get installation instructions and the JDK download for their platform at http://developer.apple.com/java/, please note that Java 5 is supplied as standard with OS X 10.4 and above, as such Mac OS X developers should not need to download the JDK.

NetBeans installation varies slightly between the supported platforms. In the following few sections we'll look at how to install NetBeans on each supported platform.

Microsoft Windows

For Microsoft Windows platforms, NetBeans is downloaded as an executable file named something like netbeans-6.5-windows.exe (the exact name depends on the version of NetBeans and the NetBeans pack that was selected for download). To install NetBeans on Windows platforms, simply navigate to the folder where NetBeans was installed and double-click on the executable file that was downloaded.

Mac OS X

For Mac OS X, the downloaded file is called something like netbeans-6.5-macosx.dmg (the exact name depends on the NetBeans version and the NetBeans pack that was selected for download). In order to install NetBeans, navigate to the location where the file was downloaded and double-click on it.

The Mac OS X installer contains four packages: NetBeans, Glassfish, Tomcat, and OpenESB. These four packages need to be installed individually; they can be installed by simply double-clicking on each one of them. Please note that GlassFish must be installed before.

Linux and Solaris

For Linux and Solaris, NetBeans is downloaded in the form of a shell script. The name of the file will be something like netbeans-6.5-linux.sh, netbeans-6.5-solaris-x86.sh, and netbeans-6.5-solaris-sparc.sh, depending on the version of NetBeans, the selected platform, and the selected NetBeans pack.

Before NetBeans can be installed in these platforms, the downloaded file needs to be made executable, this can be done in the command line by navigating to the directory where the NetBeans installer was downloaded and executing the following command:

chmod +x ./filename.sh

Substitute filename.sh with the appropriate file name for the platform and NetBeans pack.

Once the file is executable it can be installed from the command line:

./filename.sh

Again, substitute filename.sh with the appropriate file name for the platform and NetBeans pack.

Other Platforms

For other platforms, NetBeans can be downloaded as a platform independent zip file. The name of the zip file will be something like netbeans-6.5-200811261600.zip (the exact file name may vary, depending on the version of NetBeans downloaded and the NetBeans pack that was selected).

To install NetBeans on one of these platforms, simply extract the zip file to any suitable directory.

Installation Procedure

Even though the way to execute the installer varies slightly between platforms, the installer behaves in a similar way between all of them.

Note

One exception is the Mac OS X installer. Under Mac OS X, each individual component (NetBeans, GlassFish, Tomcat, and OpenESB) comes with its own installer and must be installed individually. GlassFish must be installed before OpenESB.

Another exception is the platform-independent zip file; in this case there is essentially no installer. Installing this version of NetBeans consists of extracting the zip file to any suitable directory.

After executing the NetBeans installation file for our platform, we should see a window similar to the one illustrated in the following screenshot:

Installation Procedure

The packs shown may vary depending on the NetBeans pack that was downloaded, the previous screen shot is for the All pack.

At this point we should click on the button labeled Next> to continue the installation.

Installation Procedure

NetBeans is dual licensed. Licenses for NetBeans include the GNU Public License (GPL) version 2 with CLASSPATH exception, and the Common Development and Distribution License (CDDL). Both of these licenses are approved by the Open Source Initiative (OSI).

To continue installing NetBeans, click on the checkbox labeled I accept the terms in the license agreement and click on the button labeled Next>.

At this point the installer will prompt us for a NetBeans installation directory, and for a JDK to use with NetBeans. We can either select new values for these or take the provided defaults.

Once we have selected the appropriate installation directory and JDK, we need to click on the button labeled Next> to continue the installation.

Installation Procedure

The installer will now prompt us for an installation directory, JDK and other information for the GlassFish 2 application server, usually the defaults are sensible, but we can change them if we have a reason to.

Installation Procedure

At this point the installer will prompt us for an installation directory for the GlassFish 3 application server, providing a sensible default.

Installation Procedure

At this point the installer will display a summary of our choices, after reviewing the summary, we need to click on the button labeled Install to begin the installation.

Installation Procedure

At this point installation will begin, the installer displays a progress bar indicating how far along in the installation it is.

Installation Procedure

After NetBeans and all related components have been installed, the installer indicates a successful installation.

Installation Procedure

On most platforms, the installer places a NetBeans icon on the desktop, the icon should look like the following image:

Installation Procedure

Starting NetBeans for the First Time

We can start NetBeans by double-clicking on its icon. We should see the NetBeans splash screen while it is starting up.

Note

If NetBeans was installed from an OS independent zip file, then the NetBeans icon will not be present in the desktop. For this particular case, NetBeans needs to be started by executing the appropriate binary under the netbeans/bin directory.

Starting NetBeans for the First Time

Once NetBeans starts, we should see a page with links to demos, tutorials, sample projects, and so on.

Starting NetBeans for the First Time

NetBeans defaults to showing this start page every time it is started, if we don't wish for this page to be displayed automatically every time NetBeans is started, we can disable this behavior by unchecking the checkbox labeled Show on Startup at the bottom of the page. We can always get the start page back by going to Help | Start Page.

Configuring NetBeans for Java EE Development

NetBeans comes pre-configured with the GlassFish 2 application server, and with the JavaDB RDBMS. If we wish to use the embedded GlassFish 2 and JavaDB RDBMS, then there is nothing we need to do to configure NetBeans.

We can, however, integrate NetBeans with other Java EE application servers such as GlassFish 1, Sun Java Application Server, JBoss, Weblogic, or WebSphere. We can also integrate NetBeans with several versions of Tomcat.

Integrating NetBeans with a Third Party Application Server

Integrating NetBeans with an application server is very simple. To do so, we need to take the following steps:

Note

In this section we will illustrate how to integrate NetBeans with JBoss 4.2.2 (the latest stable release at the time of writing). The procedure is very similar for other application servers or servlet containers.

First, we need to click on the tab labeled Services, it can be found at the top-right of the NetBeans main window.

Integrating NetBeans with a Third Party Application Server

Next, we need to right-click on the node labeled Servers in the tree inside the Services tab, and select Add Server... from the resulting pop-up menu.

Integrating NetBeans with a Third Party Application Server

Then we need to select the server to install from the list in the resulting window, and click on the button labeled Next>.

Integrating NetBeans with a Third Party Application Server

We then need to enter a location in the file system where the application server is installed and click Next>.

Integrating NetBeans with a Third Party Application Server

Finally, we need to select a Domain, Host, and Port for our application server, then click on the Finish button.

Integrating NetBeans with a Third Party Application Server

The Services tab should now display our newly added application server.

Integrating NetBeans with a Third Party Application Server

That's it! We have successfully integrated NetBeans with a third party application server.

Integrating NetBeans with a Third Party RDBMS

NetBeans comes with built-in integration with the JavaDB RDBMS system. Additionally, it comes with JDBC drivers for other RDBMS systems such as MySQL and PostgreSQL, as well as the JDBC-ODBC bridge driver to connect to RDBMS systems that don't natively support JDBC or for which a JDBC driver is not readily available.

Although the JDBC-ODBC bridge allows us to connect to most RDBMS systems without having to obtain a JDBC driver, it is usually a better idea to obtain a JDBC driver for our RDBMS. The JDBC-ODBC bridge does not offer the best performance and there are JDBC drivers available for the vast majority of RDBMS systems.

Note

In this section, we will create a connection to HSQLDB, an open source RDBMS written in Java, to illustrate how to integrate NetBeans with a third party RDBMS. The procedure is very similar for other RDBMS systems such as Oracle, Sybase, SQL Server, and so on.

Adding a JDBC Driver to NetBeans

Before we can connect to a third party RDBMS, we need to add its JDBC driver to NetBeans. To add the JDBC driver, we need to right-click on the Drivers node under the Databases node in the Services tab.

Adding a JDBC Driver to NetBeans

We then need to select a JAR file containing the JDBC driver for our RDBMS. NetBeans guesses the name of the driver class containing the JDBC driver. If more than one driver class is found in the JAR file, the correct one can be selected from the drop-down menu labeled Driver Class. We need to click the OK button to add the driver to NetBeans.

Adding a JDBC Driver to NetBeans

Once we have followed the above procedure, our new JDBC driver is displayed in the list of registered drivers.

Adding a JDBC Driver to NetBeans

Connecting to a Third Party RDBMS

Once we have added the JDBC driver for our RDBMS to NetBeans, we are ready to connect to the third party RDBMS.

Connecting to a Third Party RDBMS

Then we need to enter the JDBC URL, username, and password for our database.

Connecting to a Third Party RDBMS

After clicking the OK button, NetBeans may ask us to select a database schema.

Connecting to a Third Party RDBMS

After selecting the schema and clicking the OK button, our database is shown in the list of databases in the Services tab. We can connect to it by right-clicking on it, selecting Connect from the resulting pop-up, then entering our username and password for the database (if we chose not to allow NetBeans to "remember" the password when we added the database).

Connecting to a Third Party RDBMS

We have now successfully connected NetBeans to a third party RDBMS.

Deploying Our First Application

NetBeans comes pre-configured with a number of sample applications. To make sure everything is configured correctly, we will now deploy one of the sample applications to the integrated GlassFish application server that comes with NetBeans.

To open the sample project, we need to go to File | New Project, then select Samples | Web | Visual JSF from the categories list in the resulting pop-up window. Once we have selected Visual JSF from the categories list, a list of projects is displayed in the Projects list. For this example we need to select the Corporate Travel Center project.

Deploying Our First Applicationconfiguring, NetBeans for Java EE developmentthird party RDBMS, connecting to

Clicking on the Next> button, we are prompted to enter a Project Name and Project Location. Typically the defaults are sensible.

Deploying Our First Applicationconfiguring, NetBeans for Java EE developmentthird party RDBMS, connecting to

Once we click the Finish button, our new project is displayed in the Projects tab.

Deploying Our First Applicationconfiguring, NetBeans for Java EE developmentthird party RDBMS, connecting to

We can compile, package, and deploy our project all in one shot by right-clicking on it and selecting Run from the resulting pop-up menu.

Deploying Our First Applicationconfiguring, NetBeans for Java EE developmentthird party RDBMS, connecting to

At this point we should see the output of the build script. Also, both the integrated GlassFish application server and the integrated JavaDB RDBMS system should automatically start. The application server and RDBMS will only be started the first time we deploy our project, therefore the delay due to their initialization will not occur in subsequent deployments.

Deploying Our First Applicationconfiguring, NetBeans for Java EE developmentthird party RDBMS, connecting to

Once the project is deployed we should see NetBean's HTTP monitor. The HTTP monitor is a tool that helps us better develop web applications by providing values of request parameters, request, session and application attributes, request headers, and so on. The HTTP monitor will be discussed in detail in the next chapter.

Deploying Our First Applicationconfiguring, NetBeans for Java EE developmentthird party RDBMS, connecting to

As soon as our application was deployed, a new browser should have automatically started, displaying the default page for our new application. We can select the browser that NetBeans will use by going to Tools | Options, then selecting the appropriate browser from the Web Browser drop-down in the General tab.

Deploying Our First Applicationconfiguring, NetBeans for Java EE developmentthird party RDBMS, connecting to

The sample web application we just deployed is a Visual JSF application. The application uses a JDBC connection to the sample travel database included with NetBeans. The application uses the Woodstock JSF components that are bundled with NetBeans, and interacts with data stored in the sample travel database included with NetBeans.

Note

Visual JSF Development, a NetBeans feature that allow us to build JSF applications graphically, is covered in detail in Chapter 6, Visual Web JSF Development.

If our browser is displaying a page similar to the one above, then we can be certain that NetBeans, GlassFish, and JavaDB are all working properly and we are ready to start developing our own Java EE applications.

NetBeans Tips for Effective Development

Although NetBeans offers a wide array of features that make Java EE development easier and faster, it also has a lot of features that make Java development in general easier. In the following few sections we'll cover some of the most useful features.

Code Completion

The NetBeans code editor includes very good code completion. For example, if we wish to create a private variable, we don't need to type the whole "private" word, we can simply write the first three letters ("pri"), then hit Ctrl+Space, and NetBeans will complete the word private for us.

Code completion also works for variable types and method return values. For example, if we want to declare a variable of type java.util.List, we simply need to type the first few characters of the type, then hit Ctrl+Space. NetBeans will try to complete with types in any packages we have imported in our class. To make NetBeans attempt to complete with any type in the CLASSPATH, we need to hit Ctrl+Space again.

Code Completion

As we can see in the previous screenshot, NetBeans displays JavaDoc for the class we select from the code completion options. Another time saving feature is that the class we select from the options is automatically imported into our code.

Once we have the type of our variable, we can hit Ctrl+Space again, right after the variable, and NetBeans will suggest variable names.

Code Completion

When we want to initialize our variable to a new value, we can simply hit Ctrl+Space again and a list of valid types is shown as options for code completions.

Code Completion

In our example, our type (java.util.List) is an interface, therefore all classes implementing this interface are shown as possible candidates for code completion. Had our type been a class, both our class and all of its subclasses would have been shown as code completion candidates.

When we are ready to use our variable, we can simply type the first few characters of the variable name, then hit Ctrl+Space.

Code Completion

When we wish to invoke a method in our object, we simply type the dot at the end of the variable name, and all available methods are displayed as code completion options.

Code Completion

Notice how the JavaDoc for the selected method is automatically displayed.

Code completion also works for methods. We simply need to type the first few characters of our method name and NetBeans will automatically complete the method name, and it will also try to guess the values to pass as parameters.

Code Templates

Code templates are abbreviations for frequently used code snippets. To use a code template, we simply type it into the editor and hit the Tab key to expand the abbreviations into the full code snippet it represents.

For example, typing sout and pressing the Tab key will expand into System.out.println("");, with the caret placed between the two double quotes.

Some of the most useful code templates are listed in the table below, please note that code templates are case sensitive.

Abbreviation

Example Expanded Text

Description

Psf

public static final

Useful when declaring public static final variables.

forc

for (Iterator it = list.iterator([]); 
    it.hasNext();) {
    Object object = it.next();
}

Use a standard for loop to iterate through a collection.

fore

for (Object object : list) {
}

Use the enhanced for loop to iterate through a collection.

ifelse

if (boolVar) {
} else {
}

Generate an if-else conditional.

psvm

public static void main(String[] args) {
}

Generate a main method for our class.

soutv

System.out.println("boolVar = " +
boolVar);

Generate a System.out.println() statement displaying the value of a variable.

trycatch

try {
} catch (Exception exception) {
}

Generate a try/catch block.

whileit

while (iterator.hasNext()) {
Object object = iterator.next();
}

Generate a while loop to iterate through an Iterator.

To see the complete list of code templates, click on Tools | Options. Click on the Editor icon, then on the Code Templates tab.

Code Templatesfeatures, NetBeanscode completion

We can add our own templates by clicking on the New button. We will be prompted for the template's abbreviation. Once we enter it our new template will be added to the template list and will automatically be selected. We can then enter the expanded text for our template in the Expanded Text tab.

Keyboard Shortcuts

NetBeans offers several keyboard shortcuts that allow very fast navigation between source files. Memorizing these keyboard shortcuts allow us to develop code a lot more effectively than relying on the mouse. Some of the most useful NetBeans keyboard shortcuts are listed in this section, but this list is by no means exhaustive. The complete list of NetBeans keyboard shortcuts can be found online at http://wiki.netbeans.org/wiki/view/KeymapProfileFor60.

One useful keyboard shortcut that allows us to quickly navigate within a large Java file is Ctrl+F12. This keyboard shortcut will present an outline of the current Java file in the editor and show all of its methods and member variables.

Keyboard Shortcuts

Typing in the text field labeled Filter narrows the list of member variables and methods shown. This keyboard shortcut makes it very fast to navigate through large files.

Hitting Alt+F12 will result in a pop-up window outlining the class hierarchy of the current Java class.

Keyboard Shortcuts

We can use the above shortcut to quickly navigate to a superclass or a subclass of the current class.

Another useful keyboard shortcut is Alt+Insert. This keyboard shortcut can be used to generate frequently used code such as constructors, getter and setter methods, and so on.

Keyboard Shortcuts

The code will be generated at the current location of the caret.

Additionally, when the caret is right next to an opening or closing brace, clicking Ctrl+[ results in the caret being placed in the matching brace. This shortcut works for curly braces, parenthesis, and square brackets. Hitting Ctrl+shift+[ has a similar effect, but this key combination not only places the caret in the matching brace, it also selects the code between the two carets.

Keyboard Shortcuts

Sometimes, we would like to know all the places in our project where a specific method is invoked; hitting Alt+F7 while the method is highlighted allows us to easily find out this information.

Keyboard Shortcuts

The above keyboard shortcut works with variables as well.

NetBeans will indicate compilation errors in our code by underlining the offending line with a squiggly red line. Placing the caret over the offending code and hitting Alt+Enter will allow us to select from a series of suggestions to fix our code.

Keyboard Shortcuts

Sometimes navigating through all the files in a project can be a bit cumbersome, especially if we know the name of the file we want to open but we are not sure of its location. Luckily, NetBeans provides the Shift+Alt+O keyboard shortcut that allows us to quickly open any file in our project.

Keyboard Shortcuts

Additional useful keyboard shortcuts include Shift+Alt+F; this shortcut quickly formats our code. Ctrl+E erases the current line, much faster than highlighting the line and hitting backspace. Sometimes we import a class into our code and later decide not to use it, some of us delete the lines where the class is used but forget to delete the import line at the top of the source file. NetBeans will generate a warning about the unused import, hitting Ctrl+Shift+I will delete all unused imports in one fell swoop.

One last thing worth mentioning, even though it is not strictly a keyboard shortcut, a very useful feature of the NetBeans editor is that left-clicking on a method or variable while pressing Ctrl will turn the method or variable into a hyperlink, and NetBeans will navigate to the method or variable declaration.

Understanding NetBeans Visual Cues

In addition to offering keyboard shortcuts, code templates, and code completion, NetBeans offers a number of visual cues that allow us to better understand our code at a glance. Some of the most useful are illustrated in the next screenshot.

Understanding NetBeans Visual Cuesfeatures, NetBeanskeyboard shortcuts

When there is a warning in our code, NetBeans will alert us in two ways: it will underline the offending line with a squiggly yellow line, and it will place the icon shown below in the left margin of the offending line.

Understanding NetBeans Visual Cuesfeatures, NetBeanskeyboard shortcuts

The light bulb in the icon indicates that NetBeans has a suggestion on how to fix the problem, moving the caret to the offending line and hitting Alt+Enter will result in NetBeans offering one or more ways of fixing the problem.

Similarly, when there is a compilation error, NetBeans will underline the offending line with a red squiggly line, and place the icon shown below on the left margin of said line.

Understanding NetBeans Visual Cuesfeatures, NetBeanskeyboard shortcuts

Again the light bulb indicates that NetBeans has suggestions on how to fix the problem. Hitting Alt+Enter in the offending line will allow us to see the suggestions that NetBeans has.

NetBeans not only provides visual cues for errors in our code, it also provides other cues, for example, placing the caret next to an opening or closing brace will highlight both the opening and closing brace, as shown in the doSomething() method in the above screenshot.

Additionally, if one of our methods overrides a method from a parent class, the icon shown below will be placed in the left margin next to the method declaration.

Understanding NetBeans Visual Cuesfeatures, NetBeanskeyboard shortcuts

The icon is an upper case O inside a circle, the O, of course, stands for "override".

Similarly, when one of our methods is an implementation of one of the interfaces that our class implements, the icon shown below will be placed in the left margin of the method declaration.

Understanding NetBeans Visual Cuesfeatures, NetBeanskeyboard shortcuts

The icon is an uppercase I inside a green circle, which stands for "implements".

NetBeans also provides visual cues in the form of fonts and font colors, for example, static methods and variables are shown in italics, member variables are shown in green, and Java reserved keywords are shown in blue. All of the above cues can be seen in the screenshot at the beginning of this section.

Another nice feature of the NetBeans editor is that highlighting a method or variable highlights it everywhere it is used in the currently open file.

Left arrow icon Right arrow icon
Download code icon Download Code

Description

This book is written as a tutorial, leading you through examples to illuminate the main theory and get you working with the Entity Framework as quickly as possible. This book is for C# developers who want an easier way to create their data access layer. You will need to be comfortable with ADO.NET, but you don't need to know anything about the Entity Framework. Along the way we will create some ASP.NET applications, so being familiar with this will also help.

What you will learn

  • Develop Java web applications by leveraging NetBeans functionality Build standard JSF applications by taking advantage of NetBeans features Integrate NetBeans with third-party RDBMS Develop JavaServer Pages (JSPs) to display both static and dynamic content in a web browser Visually develop aesthetically pleasing JSF web applications with the NetBeans Visual Web designer Quickly and easily develop applications taking advantage of the Java Persistence API Implement the Model-View-Controller design pattern by using JavaBeans as the model component Take advantage of NetBeans functionality to easily develop Enterprise JavaBeans, including configuring transaction management via annotations Use static and dynamic navigation to define navigation between pages Utilize NetBeans to easily add messaging functionality to enterprise applications, through the Java Messaging Service API and through messag-driven EJBs Develop web services using NetBeans, including exposing EJB functionality as web services

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 31, 2008
Length: 400 pages
Edition : 1st
Language : English
ISBN-13 : 9781847195470
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 31, 2008
Length: 400 pages
Edition : 1st
Language : English
ISBN-13 : 9781847195470
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Can$ 184.97
Building Machine Learning Systems with Python
Can$73.99
Data Visualization: a successful design process
Can$44.99
Java EE 5 Development with NetBeans 6
Can$65.99
Total Can$ 184.97 Stars icon

Table of Contents

10 Chapters
Getting Started with NetBeans Chevron down icon Chevron up icon
Developing Web Applications with Servlets and JSPs Chevron down icon Chevron up icon
Enhancing JSP Functionality with JSTL and Custom Tags Chevron down icon Chevron up icon
Developing Web Applications using JavaServer Faces Chevron down icon Chevron up icon
Interacting with Databases through the Java Persistence API Chevron down icon Chevron up icon
Visual Web JSF Development Chevron down icon Chevron up icon
Implementing the Business Tier with Session Beans Chevron down icon Chevron up icon
Messaging with JMS and Message Driven Beans Chevron down icon Chevron up icon
Web Services Chevron down icon Chevron up icon
Putting it all Together Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(5 Ratings)
5 star 60%
4 star 20%
3 star 0%
2 star 0%
1 star 20%
Alejandro Apr 03, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
For the price paid I was expecting a book in such a worse condition. Nice surprise.
Amazon Verified review Amazon
W. Prakash Jan 07, 2009
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've been developing Netbeans plugin for Java EE development for the past eight years, and have knowledge of most part of the tools. When approached for help by Netbeans users, they were either guided to sparse documents in the Netbeans Knowledge base or a blog was written for their benefit. I wished for an one stop book, which I could point Netbeans users to. I'm glad to see that David Heffelfinger has written a book similar to what I wished for and published by Packt Publishing.The book is written to help Java developers who want to learn Java EE, as well as seasoned Java EE developers who would want to use an IDE for their development. Since Netbeans is an ideal tool for Java EE 5 development, the book explains how to develop end to end Java EE application using Netbeans IDE. Netbeans has numerous Java EE development support tools to develop a full-fledged Java EE application fairly easily. This book is not to teach you all the principles of Java EE, but to put all the Java EE related Netbeans tools into perspective so that a novice user can easily navigate through the maze of tools offered by Netbeans to develop a Java EE application from scratch.Over all Java EE 5 Development With Netbeans 6 is a good read. With lots of visual aids, the concepts are well explained. Though this book is not a dedicated book for learning Java EE technology, Java EE concepts are clearly explained where ever needed, which makes it an easy read for non Java EE developers. This book has enough information for a novice user to write an end-to-end Java EE application including the front end, back end, business logic, deployment and testing, although it does not cover all the Java EE technologies supported by Netbeans.A pleasant and useful book to read.
Amazon Verified review Amazon
Gregory R. Keyock Nov 21, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
100% Satisfied. Delivered on time. As advertised.
Amazon Verified review Amazon
Jimm Grogan Feb 24, 2009
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This was a much needed book for me. I am a newbie with enterprise concepts in general. It helped me learn Java Server Pages, Java Server Faces, Enterprise Java Beans and other beans, interfacing the database, and various other details for working with Java 5 EE and Netbeans. It is one of the few precious resources available on its combined topic. I was especially happy that it included how to integrate Java client side applications with your enterprise server application.This book was focused on Netbeans 6.1, and mentioned the menu paths and options for that during the tutorials. You had to figure out on your own how to do some details on Netbeans 6.5. Netbeans itself still has some bugs to further complicate some things.I felt this book was too focused on the details and procedures of building it's particular tutorial examples. It may be a matter of preference, but I would of liked some more attention on the overview and philosophical concepts. I started having trouble keeping straight the general role or purpose of all the different EE features, and why they were invented. An organizational chart of how the different EE concepts or features fit together would of been a nice reference.
Amazon Verified review Amazon
java ee learner Aug 03, 2010
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
This is a very poorly written book. I tried to follow the examples, but the author eliminates code and other critical steps and make me guess what to do. I end up ditching this book for online manual. Don't waste your money on an out of date, incomplete, and user unfriendly book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.

Modal Close icon
Modal Close icon