NetBeans is a Java Integrated Development Environment, IDE, which enables fast
application development with the most adopted frameworks, technologies, and servers.
Different than other IDEs, NetBeans comes already pre-packaged with a wide range of
functionality out of the box, such as support for different frameworks, servers, databases,
and mobile development.
This book does require a minimal knowledge of Java platform, more specifically the
language ifself. But the book might as well be used by either beginners, who are trying to
dip their toes in new technology, or more experienced developers, who are trying to
switch from other IDEs but want to decrease their learning curve of a new environment.
NetBeans integrates so many different technologies, many of which are present in this
book, that it is beyond the scope of this book to cover all of them in depth. We provide
the reader with links and information where to go when further knowledge is required.
What This Book Covers
Chapter 1, NetBeans Head First introduces the developer to the basics of NetBeans by
creating basic Java projects and importing Eclipse or Maven projects.
Chapter 2, Basic IDE Usage covers the creation of packages, classes, and constructors, as
well as some usability feature.
Chapter 3, Designing Desktop GUI Applications goes through the process of creating
a desktop application, then connecting it to a database and even modifying it to look
more professional.
Chapter 4, JDBC and NetBeans helps the developer to setup NetBeans with the most
common database systems on the market and shows some of the functionality built-in to
NetBeans for handling SQL.
Chapter 5, Building Web Applications introduces the usage of web frameworks such as
JSF, Struts, and GWT.3
Chapter 6, Using JavaFX explains the basic of JavaFX application states and connecting
our JavaFX app to a web service interface.
Chapter 7, EJB Application goes through the process of building an EJB application
which supports JPA, stateless, and stateful beans and sharing a service through a web
service interface.
Chapter 8, Mobile Development teaches how to create your own CLDC or CDC
applications with the help of NetBeans Visual Mobile Designer.
Chapter 9, Java Refactoring lets NetBeans refactor your code to extract classes,
interfaces, encapsulate fields, and other options.
Chapter 10, Extending the IDE includes handy examples on how to create your own
panels and wizards so you can extend the functionality of the IDE.
Chapter 11, Profiling and Testing covers NetBeans Profiler, HTTP Monitor, and
integration with tools that analyze code quality and load generator.
Chapter 12, Version Control shows how to configure NetBeans to be used with the most
common version control systems on the market.
- Creating an EJB project
- Adding JPA support
- Creating Stateless Session Bean
- Creating Stateful Session Bean
- Sharing a service through Web Service
- Creating a Web Service client
Introduction
Enterprise Java Beans (EJB) is a framework of server-side components that encapsulates
business logic.
These components adhere to strict specifications on how they should behave. This ensures
that vendors who wish to implement EJB-compliant code must follow conventions, protocols,
and classes ensuring portability.
The EJB components are then deployed in EJB containers, also called application servers,
which manage persistence, transactions, and security on behalf of the developer.
If you wish to learn more about EJBs, visit http://jcp.org/en/jsr/detail?id=318 or
https://www.packtpub.com/developer-guide-for-ejb3/book.
For our EJB application to run, we will need the application servers.
Application servers are responsible for implementing the EJB specifications and creating the
perfect environment for our EJBs to run in.
Some of the capabilities supported by EJB and enforced by Application Servers are:
- Remote access
- Transactions
- Security Scalability
NetBeans 6.9, or higher, supports the new Java EE 6 platform, making it the only IDE so far
to bring the full power of EJB 3.1 to a simple IDE interface for easy development.
NetBeans makes it easy to develop an EJB application and deploy on different Application
Servers without the need to over-configure and mess with different configuration files. It’s
as easy as a project node right-click.
Creating EJB project
In this recipe, we will see how to create an EJB project using the wizards provided
by NetBeans.
Getting ready
It is required to have NetBeans with Java EE support installed to continue with this recipe.
If this particular NetBeans version is not available in your machine, then you can download it
from http://download.netbeans.org.
There are two application servers in this installation package, Apache Tomcat or GlassFish,
and either one can be chosen , but at least one is necessary.
In this recipe, we will use the GlassFish version that comes together with NetBeans 7.0
installation package.
How to do it…
- Lets create a new project by either clicking File and then New Project, or by pressing
Ctrl+Shift+N. - In the New Project window, in the categories side, choose Java Web and in Projects
side, select WebApplication, then click Next. - In Name and Location, under Project Name, enter EJBApplication.
- Tick the Use Dedicated Folder for Storing Libraries option box.
- Now either type the folder path or select one by clicking on browse.
- After choosing the folder, we can proceed by clicking Next.
- In Server and Settings, under Server, choose GlassFish Server 3.1.
- Tick Enable Contexts and Dependency Injection.
- Leave the other values with their default values and click Finish.
The new project structure is created.
How it works…
NetBeans creates a complete file structure for our project.
It automatically configures the compiler and test libraries and creates the GlassFish
deployment descriptor.
The deployment descriptor filename specific for the GlassFish web server is
glassfish-web.xml.







Pingback: JavaPins