0% found this document useful (0 votes)
202 views67 pages

Full download Java EE 7 Development with NetBeans 8 3rd Edition David R. Heffelfinger pdf docx

The document provides information on downloading the book 'Java EE 7 Development with NetBeans 8' by David R. Heffelfinger, along with links to other related ebooks. It includes details about the book's content, author background, and the publishing company, Packt Publishing. The document also outlines the book's structure, including chapters on various Java EE topics and development techniques.

Uploaded by

haerrosler81
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
202 views67 pages

Full download Java EE 7 Development with NetBeans 8 3rd Edition David R. Heffelfinger pdf docx

The document provides information on downloading the book 'Java EE 7 Development with NetBeans 8' by David R. Heffelfinger, along with links to other related ebooks. It includes details about the book's content, author background, and the publishing company, Packt Publishing. The document also outlines the book's structure, including chapters on various Java EE topics and development techniques.

Uploaded by

haerrosler81
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Visit https://ebookfinal.

com to download the full version and


explore more ebooks

Java EE 7 Development with NetBeans 8 3rd


Edition David R. Heffelfinger

_____ Click the link below to download _____


https://ebookfinal.com/download/java-ee-7-development-
with-netbeans-8-3rd-edition-david-r-heffelfinger/

Explore and download more ebooks at ebookfinal.com


Here are some suggested products you might be interested in.
Click the link to download

Java EE 5 Development using GlassFish Application Server


1st Ed. Edition David R. Heffelfinger

https://ebookfinal.com/download/java-ee-5-development-using-glassfish-
application-server-1st-ed-edition-david-r-heffelfinger/

Java EE Development with Eclipse 2nd Edition Ram Kulkarni

https://ebookfinal.com/download/java-ee-development-with-eclipse-2nd-
edition-ram-kulkarni/

Beginning EJB 3 Java EE 7 edition Jonathan Wetherbee

https://ebookfinal.com/download/beginning-ejb-3-java-ee-7-edition-
jonathan-wetherbee/

Jasperreports Reporting for Java Developers 1st Edition


David Heffelfinger

https://ebookfinal.com/download/jasperreports-reporting-for-java-
developers-1st-edition-david-heffelfinger/
Java EE 7 Recipes A Problem Solution Approach 1st Edition
Josh Juneau (Auth.)

https://ebookfinal.com/download/java-ee-7-recipes-a-problem-solution-
approach-1st-edition-josh-juneau-auth/

Java Concepts Compatible with Java 5 6 and 7 6th Edition


Cay S. Horstmann

https://ebookfinal.com/download/java-concepts-compatible-with-
java-5-6-and-7-6th-edition-cay-s-horstmann/

Java EE 6 Pocket Guide 1st Edition Arun Gupta

https://ebookfinal.com/download/java-ee-6-pocket-guide-1st-edition-
arun-gupta/

The Java EE 5 Tutorial 2nd ed Edition Eric Jendrock

https://ebookfinal.com/download/the-java-ee-5-tutorial-2nd-ed-edition-
eric-jendrock/

Beginning Java Java 7 Edition Ivor Horton Ivor Horton

https://ebookfinal.com/download/beginning-java-java-7-edition-ivor-
horton-ivor-horton/
Java EE 7 Development with NetBeans 8 3rd Edition
David R. Heffelfinger Digital Instant Download
Author(s): David R. Heffelfinger
ISBN(s): 9781783983520, 1783983523
Edition: 3
File Details: PDF, 22.73 MB
Year: 2015
Language: english
www.allitebooks.com
Java EE 7 Development
with NetBeans 8

Develop professional enterprise Java EE applications


quickly and easily with this popular IDE

David R. Heffelfinger

BIRMINGHAM - MUMBAI

www.allitebooks.com
Java EE 7 Development with NetBeans 8

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: October 2008

Second edition: June 2011

Third edition: January 2015

Production reference: 1270115

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78398-352-0

www.packtpub.com

www.allitebooks.com
Credits

Author Project Coordinator


David R. Heffelfinger Akash Poojary

Reviewers Proofreaders
Saurabh Chhajed Ting Baker
Halil Karaköse Simran Bhogal
Mario Pérez Madueño Samuel Redman Birch
David Salter Maria Gould
Manjeet Singh Sawhney Ameesha Green
Paul Hindle
Acquisition Editor
Bernadette Watkins
Sam Wood

Indexer
Content Development Editors
Tejal Soni
Madhuja Chaudhari
Anand Singh Production Coordinator
Aparna Bhagat
Technical Editor
Pramod Kumavat Cover Work
Aparna Bhagat
Copy Editors
Roshni Banerjee
Neha Karnani

www.allitebooks.com
About the Author

David R. Heffelfinger is the Chief Technology Officer (CTO) at Ensode


Technology, LLC, a software consulting firm based in the Greater Washington DC
area. He has been architecting, designing, and developing software professionally
since 1995. He has been using Java as his primary programming language since
1996. He has worked on many large-scale projects for several clients, including the
U.S. Department of Homeland Security, Freddie Mac, Fannie Mae, and the U.S.
Department of Defense. He has a master's degree in software engineering from
Southern Methodist University, Dallas, Texas. David is the editor-in-chief of Ensode.
net (http://www.ensode.net), a website on Java, Linux, and other technologies.
David is a frequent speaker at Java conferences such as JavaOne. You can follow
David on Twitter at @ensode.

www.allitebooks.com
About the Reviewers

Saurabh Chhajed is a Cloudera Certified Developer for Apache Hadoop and Sun
(Oracle) Certified Java/J2EE Programmer with 5 years of professional experience in
the enterprise application development life cycle using the latest frameworks, tools,
and design patterns. He has extensive experience of working with Agile and Scrum
methodologies and enjoys acting as an evangelist for new technologies such as NoSQL
and big data and analytics. Saurabh has helped some of the largest U.S. companies to
build their product suites from scratch. While not working, he enjoys traveling and
sharing his experiences on his blog (http://saurzcode.in).

Halil Karaköse is a freelance software architect. He graduated from Işık University


in Turkey as a computer engineer in 2005.

He has worked in the telecommunications industry for 10 years, and has worked
for Turkcell and Ericsson. In 2014, he quit his job at Ericsson to establish his own
software consultancy company, KODFARKI (http://kodfarki.com).

His primary focus is Java, Java EE, Spring, and Primefaces. He also likes to give Java
trainings. He has a keen interest in Java tools that speed up development, such as
NetBeans and IntelliJ IDEA. In his spare time, he likes running, skiing, and playing
PES.

www.allitebooks.com
Mario Pérez Madueño was born in 1975 in Turin and lives in Barcelona. He
graduated in computer engineering from the Open University of Catalonia (UOC),
Spain, in 2010. Mario is a Java SE, ME, and EE enthusiast and has been a member of
the NetBeans Community Acceptance Testing program (NetCAT) for many years.
He was also the technical reviewer of the books, Java EE 5 Development with NetBeans
6 and Building SOA-based Composite Applications Using NetBeans IDE 6, 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, and Martín and Matías
for giving me the strength to go ahead.

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

I would like to thank my family for supporting me. Special thanks


and love to my wife.

www.allitebooks.com
Manjeet Singh Sawhney currently works for a large IT consultancy in
London, UK, as a Principal Consultant - Enterprise Data Architect within the
Global Enterprise Architecture Consulting practice. Previously, he worked for
global organizations in various roles, including development, technical solutions
consulting, and data management consulting. Although Manjeet has worked across
a range of programming languages, he specializes in Java. During his postgraduate
studies, he also worked as a Student Tutor for one of the top 100 universities in the
world, where he was teaching Java to undergraduate students and was involved
in marking exams and evaluating project assignments. Manjeet acquired his
professional experience by working on several mission-critical projects serving
clients in the financial services, telecommunications, manufacturing, retail, and
public sectors.

I am very thankful to my parents; my wife, Jaspal; my son, Kohinoor;


and my daughter, Prabhnoor, for their encouragement and patience,
as reviewing this book took some of my evenings and weekends
from the family.

www.allitebooks.com
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 [email protected] 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.
TM

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.

www.allitebooks.com
Table of Contents
Preface 1
Chapter 1: Getting Started with NetBeans 7
Introduction 7
Obtaining NetBeans 9
Installing NetBeans 12
Microsoft Windows 12
Mac OS X 12
Linux 13
Other platforms 13
Installation procedure 13
Starting NetBeans for the first time 20
Configuring NetBeans for Java EE development 21
Integrating NetBeans with a third-party application server 22
Integrating NetBeans with a third-party RDBMS 25
Adding a JDBC driver to NetBeans 26
Connecting to a third-party RDBMS 27
Deploying our first application 30
NetBeans tips for effective development 33
Code completion 33
Code templates 37
Keyboard shortcuts 40
Understanding NetBeans visual cues 44
Accelerated HTML5 development support 46
Summary 51

www.allitebooks.com
Table of Contents

Chapter 2: Developing Web Applications Using


JavaServer Faces 2.2 53
Introduction to JavaServer Faces 53
Developing our first JSF application 54
Creating a new JSF project 54
Modifying our page to capture user data 60
Creating our CDI named bean 66
Implementing the confirmation page 70
Executing our application 71
JSF validation 72
Facelets templating 76
Adding the Facelets template 77
Using the template 80
Resource library contracts 85
Composite components 91
Faces flows 96
HTML5 support 102
HTML5-friendly markup 102
Pass-through attributes 106
Summary 107
Chapter 3: JSF Component Libraries 109
Using PrimeFaces components in our JSF applications 109
Using ICEfaces components in our JSF applications 116
Using RichFaces components in our JSF applications 124
Summary 130
Chapter 4: Interacting with Databases through
the Java Persistence API 131
Creating our first JPA entity 132
Adding persistent fields to our entity 141
Creating a data access object 142
Automated generation of JPA entities 149
Named queries and JPQL 157
Bean Validation 159
Entity relationships 159
Generating JSF applications from JPA entities 167
Summary 174
Chapter 5: Implementing the Business Tier with Session Beans 175
Introducing session beans 176
Creating a session bean in NetBeans 176

[ ii ]
Table of Contents

Accessing the bean from a client 188


Executing the client 191
Session bean transaction management 191
Implementing aspect-oriented programming with interceptors 193
Implementing the Interceptor class 194
Decorating the EJB with the @Interceptors annotations 196
The EJB Timer service 197
Generating session beans from JPA entities 200
Summary 205
Chapter 6: Contexts and Dependency Injection 207
Introduction to CDI 207
Qualifiers 214
Stereotypes 219
Interceptor binding types 222
Custom scopes 227
Summary 229
Chapter 7: Messaging with JMS and Message-driven Beans 231
Introduction to JMS 231
Creating JMS resources from NetBeans 232
Implementing a JMS message producer 238
Consuming JMS messages with message-driven beans 245
Seeing our messaging application in action 250
Summary 251
Chapter 8: Java API for JSON Processing 253
The JSON-P object model API 253
Generating JSON data with the JSON-P object model API 254
Our example in action 256
Parsing JSON data with the JSON-P object model API 260
The JSON-P streaming API 264
Generating JSON data with the JSON-P streaming API 265
Parsing JSON data with the JSON-P streaming API 267
Summary 269
Chapter 9: Java API for WebSocket 271
Examining the WebSocket code using samples included
with NetBeans 271
The sample Echo application in action 273
Examining the generated Java code 274
Examining the generated JavaScript code 275

[ iii ]
Table of Contents

Building our own WebSocket applications 277


Developing the user interface 280
Developing the WebSocket server endpoint 282
Implementing WebSocket functionality on the client 285
Summary 289
Chapter 10: RESTful Web Services with JAX-RS 291
Generating a RESTful web service from an existing database 292
Analyzing the generated code 294
Testing our RESTful web service 299
Generating RESTful Java client code 306
Generating RESTful JavaScript clients for our
RESTful web services 313
Summary 317
Chapter 11: SOAP Web Services with JAX-WS 319
Introduction to web services 319
Creating a simple web service 320
Testing our web service 326
Developing a client for our web service 328
Exposing EJBs as web services 333
Implementing new web services as EJBs 333
Exposing existing EJBs as web services 336
Creating a web service from an existing WSDL 339
Summary 342
Index 343

[ iv ]
Preface
Java EE 7, the latest version of the Java EE specification, adds several new features
to simplify enterprise application development. New versions of existing Java EE
APIs have been included in this latest version of Java EE. JSF 2.2 has been updated
to better support wizard-like interfaces via FacesFlows and has been enhanced to
better support HTML5. NetBeans supports JPA 2.1 features such as Bean Validation
and many others. EJB session beans can be automatically generated by NetBeans,
allowing us to easily leverage EJB features such as transactions and concurrency.
CDI advanced features such as qualifiers, stereotypes, and others can be easily
implemented via NetBeans' wizards. JMS 2.0 has been greatly simplified, allowing us
to quickly and easily develop messaging applications. Java EE includes a new Java
API for JSON Processing (JSON-P), allowing us to quickly and easily process JSON
data. NetBeans includes several features to allow us to quickly and easily develop
both RESTful and SOAP-based web services.

This book will guide you through all the NetBeans features that make the
development of enterprise Java EE 7 applications a breeze.

What this book covers


Chapter 1, Getting Started with NetBeans, provides an introduction to NetBeans,
giving time-saving tips and tricks that will result in more efficient development
of Java applications.

Chapter 2, Developing Web Applications Using JavaServer Faces 2.2, explains how
NetBeans can help us easily develop web applications that take advantage of the
JavaServer Faces 2.2 framework.
Preface

Chapter 3, JSF Component Libraries, covers how NetBeans can help us easily develop
JSF applications using popular component libraries such as PrimeFaces, RichFaces,
and ICEfaces.

Chapter 4, Interacting with Databases through the Java Persistence API, explains how
NetBeans allows us to easily develop applications taking advantage of the Java
Persistence API (JPA), including how to automatically generate JPA entities from
existing schemas. This chapter also covers how complete web-based applications
can be generated with a few clicks from an existing database schema.

Chapter 5, Implementing the Business Tier with Session Beans, discusses how NetBeans
simplifies EJB 3.1 session bean development.

Chapter 6, Contexts and Dependency Injection, discusses how the CDI API introduced
in Java EE 6 can help us integrate the different layers of our application.

Chapter 7, Messaging with JMS and Message-driven Beans, explains Java EE messaging
technologies such as the Java Message Service (JMS) and Message-driven Beans
(MDB), covering NetBeans' features that simplify application development taking
advantage of these APIs.

Chapter 8, Java API for JSON Processing, explains how to process JSON data using the
new JSON-P Java EE API.

Chapter 9, Java API for WebSocket, explains how to use the new Java API for
WebSocket to develop web-based applications featuring full duplex communication
between the browser and the server.

Chapter 10, RESTful Web Services with JAX-RS, covers RESTful web services with
the Java API for RESTful Web Services, including coverage of how NetBeans can
automatically generate RESTful web services and both Java and JavaScript RESTful
web service clients.

Chapter 11, SOAP Web Services with JAX-WS, explains how NetBeans can help us
easily develop SOAP web services based on the Java API for the XML Web Services
(JAX-WS) API.

What you need for this book


You need Java Development Kit (JDK) version 7.0 or newer and NetBeans 8.0 or
newer Java EE edition.

[2]
Preface

Who this book is for


If you are a Java developer who wishes to develop Java EE applications while taking
advantage of NetBeans' functionality to automate repetitive tasks and ease your
software development efforts, this is the book for you. Familiarity with NetBeans
or Java EE is not 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:
"NetBeans uses the JAVA_HOME environment variable to populate the JDK's
directory location."

A block of code is set as follows:


<package com.ensode.flowscope.namedbeans;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.faces.flow.FlowScoped;
import javax.inject.Named;

@Named
@FlowScoped("registration")
public class RegistrationBean {
...

When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
package com.ensode.flowscope.namedbeans;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.faces.flow.FlowScoped;
import javax.inject.Named;

@Named
@FlowScoped("registration")
public class RegistrationBean {
...

[3]
Preface

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


chmod +x filename.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: " To
download NetBeans, we need to click on the Download button."

Warnings or important notes appear in a box like this.

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 [email protected], 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.

[4]
Preface

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 [email protected] 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
[email protected], and we will do our best to address the problem.

[5]
Getting Started with
NetBeans
In this chapter, we will learn how to get started with NetBeans. The following topics
are covered in this chapter:

• Introduction
• Obtaining 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 through built-in support, or by installing additional plugins. Programming
languages natively supported by NetBeans include Java, C, C++, PHP, HTML, and
JavaScript. Groovy, Scala, and others are supported via additional plugins.

In addition to being an IDE, NetBeans is also a platform. Developers can use


NetBeans' APIs to create both NetBeans plugins and standalone applications.
Getting Started with NetBeans

For a brief history of NetBeans, see http://netbeans.org/


about/history.html.

Although the NetBeans IDE supports several programming languages, because


of its roots as a Java only IDE it is more widely used and known within the Java
community. As a Java IDE, NetBeans has built-in support for Java SE (Standard
Edition) applications, which typically run on a user's desktop or notebook computer;
Java ME (Micro Edition) applications, which typically run on 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 application development using JavaServer Faces (JSF), the standard Java EE
component based web framework by providing a starting point for these kinds of
artifacts. We will also see how NetBeans can help us generate Java Persistence API
(JPA) entities from an existing database schema (JPA is the standard object-relational
mapping tool included with Java EE).

In addition to web development, we will see how NetBeans allows us to easily


develop Enterprise JavaBeans (EJBs); 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 aforementioned NetBeans features, we of course


need to have NetBeans installed, as covered in the next section.

[8]
Chapter 1

Obtaining NetBeans
NetBeans can be obtained by downloading it from http://www.netbeans.org.

[9]
Getting Started with NetBeans

To download NetBeans, we need to click on the Download button. Clicking on this


button will take us to a page displaying all NetBeans' download bundles.

NetBeans' downloads include different NetBeans bundles that provide different


levels of functionality. The following table summarizes the different NetBeans
bundles available and describes the functionalities they provide.

NetBeans Bundle Description


Java SE Allows development of Java desktop applications.
Java EE Allows development of Java Standard Edition (typically
desktop) applications, and Java Enterprise Edition applications
(enterprise applications running on "big iron" servers).
C/C++ Allows development of applications written in the C or C++
languages.

[ 10 ]
Chapter 1

NetBeans Bundle Description


HTML5 and PHP Allows development of web applications using HTML5 and/or
the popular open source PHP programming language.
All Includes functionalities of all NetBeans bundles.

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

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

The following platforms are officially supported by NetBeans:

• Windows
• Linux (x86/x64)
• Mac OS X

Additionally, NetBeans can be executed on any platform containing Java 7 or newer


version. To download a version of NetBeans to be executed in one of these platforms,
an OS independent of NetBeans is available.

Although the OS independent version of NetBeans can be


executed in all 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 as Platform.

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

[ 11 ]
Getting Started with NetBeans

Java EE applications need to be deployed on an application server.


Several application servers exist in the market; both the Java EE and
the All NetBeans bundles come with GlassFish and Tomcat bundled.
Tomcat is a popular open source servlet container, which can be used to
deploy applications using JSF. However, it does not support other Java
EE technologies such as EJBs or JPA. 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 1.7 or newer to be
available before it can be installed.

Since this book is aimed at experienced Java developers, we will not


spend much time explaining how to install and configure the JDK. We
can safely assume that the target market for the book is more than likely
to have a JDK installed. Installation instructions for the Java Development
Kit can be found at http://docs.oracle.com/javase/7/docs/
webnotes/install/index.html.

NetBeans installation varies slightly between the supported platforms. In the following
few sections we explain 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-8.0-javaee-windows.exe (exact name
depends on the version of NetBeans and the NetBeans bundle that was selected
for download). To install NetBeans on Windows platforms, simply navigate to the
folder where NetBeans was downloaded and double-click on the executable file.

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

[ 12 ]
Chapter 1

Linux
For Linux, NetBeans is downloaded in the form of a shell script. The name of the file
will be similar to netbeans-8.0-javaee-linux.sh (exact name will depend on the
version of NetBeans and the selected NetBeans bundle).

Before NetBeans can be installed on Linux, the downloaded file needs to be


made executable, which can be done using a 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 in the preceding command with the appropriate filename


for the platform and NetBeans bundle. Once the file is executable it can be installed
from the command line as follows:
./filename.sh

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-8.0-201403101706-
javaee.zip (exact filename may vary, depending on the exact version of NetBeans
downloaded and the NetBeans bundle 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 most of them.

One exception is the platform independent ZIP file, in which there is


essentially no installer. Installing this version of NetBeans consists of
extracting the ZIP file to any suitable directory.

[ 13 ]
Getting Started with NetBeans

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

The pack shown may vary depending on the NetBeans bundle that was downloaded.
The preceding screenshot is for the Java EE bundle.

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

[ 14 ]
Chapter 1

NetBeans is dual licensed, licenses for NetBeans include the GNU Public License
(GPL) Version 2 with the 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>.

[ 15 ]
Getting Started with NetBeans

NetBeans comes bundled with JUnit, a popular Java unit testing framework. JUnit's
license differs from the NetBeans license, so it needs to be accepted separately.
Clicking the Next> button takes us to the next step in the installation wizard:

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

NetBeans uses the JAVA_HOME environment variable to populate


the JDK's directory location.

[ 16 ]
Chapter 1

The installer will now prompt us for an installation directory for the GlassFish
application server, as well as for the JDK to use for GlassFish; we can either enter
a custom directory or accept the default values and then click on Next>.

[ 17 ]

www.allitebooks.com
Getting Started with NetBeans

If we chose to install Tomcat, the installer will prompt us for a Tomcat installation
directory. Again, we can either enter a custom directory or accept the default values
and then click on Next>.

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.

[ 18 ]
Chapter 1

As the installation begins, the installer starts displaying a progress bar indicating the
progress of installation.

After NetBeans and all related components have been installed, the installer indicates
a successful installation, giving us the option to contribute anonymous usage data as
shown in the preceding screenshot. After making our selection we can simply click
on the Finish button to exit the installer.

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

We can start NetBeans by double-clicking on the icon.

[ 19 ]
Getting Started with NetBeans

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.

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

[ 20 ]
Chapter 1

Every time NetBeans is launched, it shows the default start page as illustrated in the
preceding screenshot. If we don't want this page to be displayed automatically every
time NetBeans is started, we can disable this behavior by un-checking the checkbox
labeled as Show on Startup at the top 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 preconfigured with the GlassFish application server, and with the
JavaDB RDBMS. If we wish to use the included GlassFish application server 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 JBoss/
WildFly, WebLogic, or WebSphere and with other relational database systems such
as MySQL, PostgreSQL, Oracle, or any RDBMS supported by JDBC, which pretty
much means any RDBMS.

[ 21 ]
Getting Started with NetBeans

Integrating NetBeans with a third-party


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

In this section, we will illustrate how to integrate NetBeans with


JBoss, the procedure is very similar for other application servers
or servlet containers.

1. First, we need to click on Window | Services.

[ 22 ]
Chapter 1

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

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

[ 23 ]
Getting Started with NetBeans

4. We then need to enter a location in the filesystem where the application


server is installed and click Next>.

5. Finally, we need to select a domain, host, and port for our application server,
then click on the Finish button.

[ 24 ]
Chapter 1

The Services window should now display our newly added 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 Oracle, MySQL, and PostgreSQL.

To integrate NetBeans with a third-party RDBMS, we need to tell NetBeans the


location of its JDBC driver.

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, among others.

[ 25 ]
Getting Started with NetBeans

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.

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 on the OK button to add
the driver to NetBeans as shown in the following screenshot:

[ 26 ]
Chapter 1

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

Connecting to a third-party RDBMS


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

To connect to our third-party RDBMS, we need to right-click on its driver under the
Services tab, then click on Connect Using... on the resulting pop-up menu as shown
in the following screenshot:

[ 27 ]
Exploring the Variety of Random
Documents with Different Content
and Loli, and Kohenemonemo Loli, ame ka laua wahine o
the wife of the two men. Kohenemonemo.

When Lonoikamakahiki was I ko Lonoikamakahiki wa


quite young, when he was just opiopio, oiai ua hoomaka ae
about beginning to reason for kona noonoo ana, ia manawa
himself, he looked up one day nana ae la o Lonoikamakahiki, e
and saw the various implements kau ana na mea lealea a kona
used by his father in the different makuakane he nui maloko o ka
games, which were hanging up hale alii; a ike ae la oia e kau
in the palace; when he saw the ana na ihe-pahee, nana loihi ae
long spear used in the game of la oia, a liuliu, alaila, ninau aku la
pahee 3 he looked at it for a long oia i kona mau kahu: “Heaha
time and then asked his keia mau mea loloa e kau nei
retainers: “What are those long iluna o ka hale?” I aku la na
things hanging up there on the kahu: “He ihe-pahee.” Ninau hou
side of the house?” The retainers aku la o Lonoikamakahiki:
replied: “They are pahee “Heaha kana waiwai?” Alaila hai
spears.” Lonoikamakahiki again aku la na kahu: “Elua mau
asked them: “What are they kanaka e manao ana e lealea pili
used for?” The retainers then waiwai, alaila hele laua a ma ke
told him: “When two men wish to kahua pahee; a i ka hiki ana
wager certain articles of value, malaila, alaila, olelo ka pili a
they would proceed to the pahee holo, ina he mau waiwai ka pili, a
grounds and upon arriving at the i ole, he mau aina paha; a ina
place they would decide first as aole i pili ia ma ia mau waiwai,
to the wager, whether it be alaila, o ka pili no i na iwi ka pili,
articles of value or pieces of alaila pahee, ina he
land. If they do not wager these umikumamalima ka ai (ka helu).
things, then they would put up A ina ua hiki e aku kekahi i ka ai
other things, such as their eo (i ka helu pau) a emi mai
bones, meaning their lives. After paha kona hoa pahee, alaila o
the bets are agreed on, they ke eo ae la no ia, ina paha o ka
would then proceed to play the waiwai ke kumu pili, alaila o ke
game of pahee. If the points to eo ae la no ia o ka waiwai; ina
be scored in order to win the ua nui ka waiwai o ka pili ana,
game be made fifteen, then the ekolu, eha hale e piha i ka
one who first obtains this number waiwai. Aka ina o na kino o laua
of points would win and the one ka pili, alaila, o ka make no o
with the lesser points would lose; kekahi o laua ka hope. Aole nae
then the winner takes the articles he pili nui ia oia mea; aia no a ku
wagered, or whatever had been ka hoopaapaa mawaena o na
placed as wagers. Sometimes aoao elua, e hoole ana kekahi a
the articles of value would be so me kekahi i na akamai o laua,
great that it would take three and alaila pili kino ia; a oia la, pela
four houses to hold them all. But iho la ka waiwai o ia mea.”
if the things wagered be their
bones, then death of course
would be meted out to the loser.
Wagering for bones was not
made very often, only when the
parties entered into the merits of
their skill by long and spirited
arguments, each claiming to be
superior to the other. That is the
use of those long things you
see.”

When Lonoikamakahiki heard A lohe o Lonoikamakahiki i keia


this explanation he replied: mea, olelo ae la oia: “Aole ana
“Those things are worthless and waiwai; aka, he waiwai no,
have very little use; the great hookahi no hewa, o ka pili ana i
objection I have against them is na iwi ke hiki mai i ka manawa e
that they are used by men for the hoopaapaa ai na mea pahee i ko
purpose of making wagers, even laua mau ike, nolaila ka waiwai
to the extent of their bones, on ole oia mea.” I aku la na kahu:
the result of their skill after “Oia iho la no ka waiwai oia mea
heated arguments. That is the (pahee) i malamaia ai e kou
reason they are [258]worthless.” makuakane.” [259]
The retainers then said: “That is
what the pahee spears are used
for and the reason why they are
being kept by your father.”

Lonoikamakahiki again looked Ia manawa, nana hou ae la oia,


up and saw a round, flat stone a iki i ka olohu (ulu maika) ninau
and again asked: “What is that hou ae la oia: “Heaha kela
thing?” The retainers replied: “It mea?” Hai aku la no na kahu:
is called an olohu.” 4 “He olohu.” Ninau aku o
Lonoikamakahiki again asked: Lonoikamakahiki: “Heaha hoi ka
“What is it used for?” Then the waiwai oia mea?” Alaila hai aku
retainers told him that it was la no na kahu e like me ka olelo
used in the same way and for ana no ka ihe pahee. I hou aku o
the same purpose as the pahee Lonoikamakahiki: “E kiola, aole
spears. At this Lonoikamakahiki ana waiwai.”
replied: “Throw it away; it is also
worthless.”

Again Lonoikamakahiki looked, Nana hou ae la no ua o


and when he saw the sugar- Lonoikamakahiki, a ike i ka pua
cane top, used as an arrow, he kea, ninau hou aku la no i na
asked of his retainers: “What is kahu: “Heaha hoi kela?” Hai aku
that?” The retainers replied: “It is la na kahu: “He pua kea.” Ninau
an arrow made from the sugar- hou aku no ua o
cane top.” Lonoikamakahiki Lonoikamakahiki: “A pehea hoi
again asked: “And what is it used kana hana?” Hai aku la no na
for?” The retainers replied: “It is kahu: “He mea lealea no ia; ina
also used in games. If two or elua a ekolu paha mau mea e
three fellows wish to play the kea pua ana, a ina i lele ka
game with the arrows 5 they go to kekahi a oi loa mamua o ka
the playground and see who kekahi mau mea alaila, o ka eo
could glide his arrow on the ae la no ia. A ina he pili ma ka
ground the farthest. The one waiwai, ua like no ka waiwai me
who can send it the farthest ko ka pahee ana, ke nui no hoi
wins. If articles of value have ka pili ana.” I aku la o
been placed as wagers the Lonoikamakahiki: “Aole ana
winner takes them. It is used in waiwai, e pono ke haihai a kiola
the same way and for the same aku.”
purpose as the pahee spears,
and large wagers have been lost
and won on the game.”
Lonoikamakahiki then replied: “It,
too, is worthless; you had better
break it up and throw it away.”

Again Lonoikamakahiki looked Nana hou ae la no ua o


up, and when he saw a wooden Lonoikamakahiki, a ike ae la i ka
club he asked: “And what is that laau palau, ninau ae la: “Heaha
thing?” The retainers replied: “It hoi kela?” I aku na kahu: “He
is a wooden club.” 6 laau palau?” Ninau hou aku la o
Lonoikamakahiki again asked: Lonoikamakahiki: “Heaha kana
“And what is its purpose?” The hana?” Hai aku la na kahu: “He
retainers replied: “It is an mea pepehi aku i na kanaka, ina
implement of war and used to kill paha he hoouka kaua mai ko
people with. If a battle is being kekahi aoao, a hoouka aku ko
fought with one side opposing kekahi aoao, alaila o ka laau
the other then the war club palau ka mea e luku aku ai. A
comes in use as an implement of ina e kaua aku me ua laau palau
war. When this club is used in nei, alaila, he kanaha kanaka e
war it can kill as many as forty make i ka laau palau hookahi, a
people, and sometimes it will kill ina no he nui aku, oia no.” I aku
more people than that.” la ua o Lonoikamakahiki: “Aole
Lonoikamakahiki then said: “That no ana waiwai, hookahi ana
thing is also without value. Its waiwai, he ulu imu.”
only use would be for a stick to
turn over the stones in an umu.” 7

Again Lonoikamakahiki looked Nana hou ae la no ua o


up and saw a bundle of war Lonoikamakahiki nei, e kau ana
spears; 8 he then asked: “What ka ihe kaua, ninau ae la: “Heaha
are those things?” The retainers kela?” I aku na kahu: “He mea
replied: “They are also used to luku kanaka no, he mea luku aku
kill people with. In times of war i na kanaka ke kaua mai, ina i
when men are fighting each kahi e, e hou aku ai, ku aku la no
other these spears are used at ke kanaka. A ina he akamai mai
close quarters by thrusting, and kekahi aoao i ka pale ana o ka
at long range by throwing, at the ihe, alaila, aole e ku.” I aku o
enemy. These spears in the Lonoikamakahiki: “Ae, he mea
hands of strong men can be waiwai ia, aka, o ka mea akamai
thrown for some distance. If the i ka alo ihe ke kanaka waiwai;
person on the other side is of nolaila, he hana waiwai ia a kuu
great skill he could ward off one makuakane, nolaila, ina eia no
or more spears at a time, and in kuu piko ke waiho nei, alaila, e
that way avoid being hit.” nikii pu i kuu piko me ka pua ihe
Lonoikamakahiki then said: “Yes, a kuu makuakane.”
those things are of some value;
but the person who can skilfully
ward them off is of more
importance. These things of my
father’s are of some value;
therefore, if my navel string is
still in your keeping, then tie it
together with my father’s bundle
of war spears.” [260]
Lonoikamakahiki again looked, Nana hou ae la no ua o
and seeing the strings of a sling Lonoikamakahiki, a o ke kau a
hanging he asked: “What is the ke kaula maa, ninau ae la:
use of those strings hanging “Heaha ka waiwai o kela mau
from the wall?” The retainers kaula e lewalewa mai nei?” Hai
replied: “They belong to the aku la na kahu: “He maa.” Ninau
sling.” 9 Lonoikamakahiki again hou aku o Lonoikamakahiki:
asked: “What is it used for?” The “Heaha hoi kona waiwai?” Hai
retainers replied: “A stone is aku la na kahu: “E hookomo i ka
placed in the opening in the pohaku ma ka puka o ka maa,
middle of the sling, then the ends alaila, e pelu mai ina piko elua o
of the strings are brought ua maa la, a e hoopaa ae i ka
together and held in the palm of piko o na kaula o ua maa la i ka
the sling hand; then swing the poho o ka lima e makaukau
sling around the head and when [261]ana i ka hana; alaila, e wili
you think it time to let go, one of ae, a kowali ae, a e like me kona
the ends of the string is released manawa i manao ai e hoolele
which allows the stone to fly out aku i ka pohaku, alaila, e haalele
at the same time. Sometimes the loa aku i kekahi piko o ka maa,
stone would fly over forty alaila e lele aku ka pohaku, he
fathoms, and if a person is struck kanaha a oi aku na anana e lele
with it the force would kill the ai, a ina i pa aku i ka pohaku,
person. It is, however, used as make loa kekahi kanaka. I
an implement of war.” hanaia no nae no ke kaua.” I aku
Lonoikamakahiki then said: “That la o Lonoikamakahiki: “Alua mea
makes two things of value waiwai a kuu makuakane; nakii
belonging to my father. Tie it up pu ia aku me ka pua ihe.” Pela
with the bundle of spears.” kona ninau ana i na mea lealea
Lonoikamakahiki in this manner a pau a kona makuakane; ua
inquired into the use of all the hooleia ka waiwai o na mea
things kept by his father. He apau, a elua wale no mau mea a
denied the usefulness of Lonoikamakahiki i mahalo.
everything but two, which two
things he had the greatest desire
to reserve for his own use.

Sometime after this, I kekahi manawa ae, hele aku la


Lonoikamakahiki again visited no o Lonoikamakahiki a ka hale i
the house where the different waiho ai na mea lealea, nana ae
implements of war and games la, e kau ana no na mea ana i
were kept, and again looked and olelo ai i na kahu, e haihai a
saw the things he had ordered to kiola; nolaila, hoi aku la oia a
be broken and destroyed still kona mau kahu, olelo aku la:
hanging in their respective “Kai noa, ua kiola olua i na mea
places, so he returned and a’u i olelo aku ai ia olua?” I aku
asked of his retainers: “I thought la kona mau kahu: “Aole e hiki ia
you two had destroyed those maua ke kiola i na mea a ko
things that I told you to.” His two makuakane; make mai paha
retainers answered him saying: maua, no ka mea, o ka laau
“We cannot destroy the things palau a ko makuakane, he laau
belonging to your father, for he hai kanaka ia.” A no ka paakiki
would consider it a matter loa o Lonoikamakahiki, nolaila,
sufficient to cause our death, hele aku la na kahu, a hai aku la
because the war club is one of ia Keawenuiaumi, i keia mau
the things highly valued by your hana a kana keiki.
father, for it has been used in his
great battles, and it has been the
means of killing many of his
enemies.” Lonoikamakahiki
becoming very stubborn in the
matter, the retainers therefore
went to Keawenuiaumi and
reported to him the wish of his
son.

When Keawenuiaumi heard this Ia manawa, lohe ae la o


report he was greatly surprised Keawenuiaumi, alaila, haohao
because of the strange wish iho la oia i keia hana kupanaha a
expressed by his son. He kana keiki; nolaila, hele aku la
therefore sought out oia e ninau maopopo ia
Lonoikamakahiki with the Lonoikamakahiki i ke kumu o ko
intention of asking him why he ke keiki manao ana pela. Nolaila
wished to have these things i ka hiki ana aku o
destroyed. When Keawenuiaumi Keawenuiaumi i kahi i hanai ia ai
came to the place where the boy e na kahu, aia nae ua o
was being cared for by the Lonoikamakahiki i ka
retainers, he found that hooholowaa me kekahi mau
Lonoikamakahiki was out canoe kahu ona. A hoi mai la ua o
sailing with some of his other Lonoikamakahiki, e noho aku
retainers. When ana o Keawenuiaumi, hele mai
Lonoikamakahiki returned la ke keiki a noho iho la i luna o
Keawenuiaumi was waiting for na uha o ka makuakane; alaila, i
him; the boy then went up to the mea e maopopo ai ia
father and sat on his lap. 10 In Keawenuiaumi ko
order to have the matter Lonoikamakahiki manao, nolaila,
understood by his son properly lawe ae la kona makuakane iaia
Keawenuiaumi took i kahi i waiho ai na mea lealea. A
Lonoikamakahiki to the house hiki aku la laua, me na kahu pu
where the different implements ma ka hale i waiho ai na mea
of war and games were kept, lealea, ninau aku la o
and there the father asked the Keawenuiaumi: “Heaha kou
son: “What do you think of these manao no neia mau mea (na
things?” meaning the mea lealea ame na mea kaua) e
implements of war and games kau nei?” I ae la ke keiki
hanging on the wall. The son (Lonoikamakahiki): “Aole he
replied: “These things are of no waiwai iki o keia mau mea, ua
value or use. I have told those olelo aku wau ia laua ’la (Hauna
two (Hauna and Loli) to destroy ame Loli) e kiola keia mau mea
them all, but to keep the bundle a pau, a o ka ihe kaua ame ka
of spears and the sling, for they maa na mea waiwai.” I aku la o
are of value.” Keawenuiaumi Keawenuiaumi: “Aole pela ko’u
then said to the boy: “That is not manao, aia no a hiki i kou noho
what I think about those things. aimoku ana, alaila, nau no e
When the time comes for you to kiola, ke ike aku la oe, he mea
assume the care of the whole waiwai ole kela.”
island, then you will be in a
position to do as you like; you
can then throw these things
away if you see no use in
retaining them.”

After this incident Keawenuiaumi Ma ia hope mai, nalu wale iho la


for some time thought over the no o Keawenuiaumi i ka hope o
future of the boy and wondered keia keiki ke nui ae. I iho a ka
what would become of him after makuakane: “Ane kipi wale aku
he had grown up. The father said no koe o keia keiki ma kona
[262]to himself: “It looks as though noho ai aina ana, a heaha la ka
the boy will some day go hana a keia alii ke kanaka
contrary to all the laws that have makua aku.” [263]
heretofore governed the
apportioning of lands, and I
wonder what this chief will do
after he has grown up.”

Sometime after this I kekahi manawa ma ia hope


Lonoikamakahiki entered the mai, komo ae la ua o
temple with his retainers and Lonoikamakahiki i loko o ka
there saw the images standing heiau me kona mau kahu, a ike
up in one of the corners, when aku la i na kii e ku mai ana ma
he asked of his retainers: “Who kuono o ka heiau, ninau aku la i
are those persons standing there na kahu: “Owai kela mau kanaka
within the wall?” His parents and e ku mai la i loko o ka pa?” I aku
retainers replied: “They are not la na makua a me na kahu:
persons; they are the gods of our “Aole ia he kanaka, he akua ia o
parents, your grandparents.” ko makou mau makua, na
When Lonoikamakahiki heard kupuna hoi ou.” A lohe o
that the images were gods he Lonoikamakahiki he akua ia mau
was sore afraid 11 and held on to kii, alaila puliki ikaika aku la i na
his parents with all his strength, makua, no ka mea, ua makau o
for he had been told by his Lonoikamakahiki, a no ka mea
playmates that ghosts were hoi, ua lohe mua oia i ka
things to be avoided and feared, hoomakaukauia e na hoa paani
and he thought the images were ona, a nolaila oia i puliki paa ai i
the ghosts. Because na makua, no kona manao o pau
Lonoikamakahiki held on to his mai i ke akua, no ka mea, ua
parents they said to him: “You oleloia e kona mau hoa kamalii:
must not be afraid; what you see “E lono-e! A-pa-u. A pau i ke
are not ghosts; they are the gods akua lapu.” A no ko
who own this place.” Lonoikamakahiki puliki ana aku, i
Lonoikamakahiki then asked of aku la na makua: “Mai makau
his parents: “What are they good oe, aole ia he akua lapu, he
for?” The parents made reply: akua ia nona keia wahi.” I aku o
“The reason why they are kept is Lonoikamakahiki i na makua:
this: If in case of battle one is “Heaha kana waiwai?” I aku la
taken captive or defeated, they na makua: “Eia kona mea i
offer a prayer to the gods, and malama ia ai; ina he kaua a pio
then the gods will direct the paha, alaila, hoomanamana aku
person to safety. If, on the other i ke akua, alaila, na ua akua la e
hand, a canoe is capsized out in alakai i kahi e pakele ai. A ina he
mid-ocean, prayers are offered waa kahuli ma ka moana, pule
to the gods and those in the no i ke akua, ola no; ina he kau
canoe will be saved. If a season wi, a pule no i ke akua, alaila ea
of famine should come, prayers mai no ka ai. Oia ka waiwai o ke
are offered to the gods and the akua i malama ia ai.” I aku o
food would again appear out of Lonoikamakahiki ia
the earth. These are some of the Keawenuiaumi: “Akolu wale no
benefits why a god should be au mea waiwai i malama ai; o
kept.” Lonoikamakahiki then said keia mau mea au ka’u e
to his father, Keawenuiaumi: malama.”
“That makes three things in your
keeping that are of value. I will
take care of these things.”

Sometime after Lonoikamakahiki Mahope mai o ko


had outgrown his childhood days Lonoikamakahiki mau la opiopio,
and had almost attained ma ka hookanaka makua iki ana
manhood, he began to learn the ae, ao ae la oia i ka alo ihe a me
art of dodging and throwing the ka oo ihe ana, a ao ae la no hoi
spear; he also learned how to oia i ke kui ame ka mokomoko, a
box and wrestle. These things akamai ae la oia ma ia mau
were in time mastered by him. hana. A i ka manawa i akamai
When he became proficient in ai, alaila, hailona aku la na kumu
these arts of defense and of war, nana i ao i kela mau hana ma ka
the teachers who had charge of ai lolo ana. A i ka ai lolo ana, ua
his training in these matters then ku kana mau hana a pau i ka
held the last customary pono ma ke akamai. A o ka
ceremonies, as a sign of hailona o ke kui ma ka lolo ana,
foretelling how he would act in oia ka lolo i ino. Nolaila olelo aku
life. The signs were favorable in la ke kumu kui: “Aole oe e pono
all the different arts with one ke ao i ke kui, no ka mea, ua ku
exception, that of boxing, which, kau lolo i ka pono ole, a nolaila,
not being favorable in this one e pono ke haalele.” Nolaila,
thing, he was advised to haalele iho la o Lonoikamakahiki
eliminate this one art from the list i ke ao ana i ke kui. Aka, ma ka
of those he was to participate in. mokomoko, oia ka oihana i oi
In other words, he was forbidden aku ko Lonoikamakahiki ike ame
from ever going into any boxing ke akamai maoli.
contest. Because of this
Lonoikamakahiki relinquished his
claims as a boxer. It was in the
art of wrestling, however, that
Lonoikamakahiki proved himself
to be the most proficient.

CHAPTER II. MOKUNA II.

How Lonoikamakahiki Ko Lonoikamakahiki Imi


Searched Into the Ana i na Hana oi o ka
Most Useful Things. Waiwai.

When Lonoikamakahiki became I ko Lonoikamakahiki wa i


older and more matured in hoonaauao loa ae ai, makemake
thought he expressed a desire to ae la oia e ike maopopo i na
know the things that would be of hana oi o ka waiwai, a nolaila,
the most use to him, especially hoao pakahi aku la oia i na hana
in the games, so he tried each lealea, ame na hana kaua a
one of them, as well as the kona makuakane, na hana hoi
different arts of warfare indulged ana i olelo ai i kona mau kahu,
in by his father, the things that he mau hana waiwai ole. [265]
were told him by his retainers as
the things most desired. [264]

After Lonoikamakahiki had tried A i ko Lonoikamakahiki hoao


these different things he was ana, maopopo iho la no he
convinced that they were of no waiwai ole ia mau mea, a e like
use, as he had said. The thrust hoi me kana olelo mua, o ka alo
and dodging spear, the sling, ihe ame ka oo ihe, ka maa ame
and the care of the god, ka malama i ke akua na hana
however, were of value. He waiwai. Aka, no ko
therefore made a visit around the Lonoikamakahiki makemake nui
island of Hawaii accompanied by e ike i ka hana i oi aku o ka
his parents and retainers. waiwai, nolaila, kaahele ae la ia
ma ka mokupuni o Hawaii, oia
ame kona mau makua ame na
kahu pu.

Hauna and his younger brother O Hauna nae ame kona kaikaina
Loli, the personal attendants or me Loli, na kahu hoi o ua o
retainers of Lonoikamakahiki, Lonoikamakahiki, he mau kaula
were prophets; they were men laua, he mau kanaka haipule
who paid attention strictly to the hoi, a ua oleloia he mau kanaka
laws of the gods, and it was said mana laua, a he hiki ia laua ke
that they were men who hana i na hana mana he nui ma
possessed supernatural powers, ka inoa o ko Keawenuiaumi
and that they were able to akua, ame ko laua akua hoi.
perform many miracles in the
name of the god of
Keawenuiaumi, and also in the
name of their own god.

In this circuit of the island made Ma keia kaapuni ana o


by Lonoikamakahiki and his Lonoikamakahiki me kona mau
parents, upon their arrival at Hilo makua, a hiki ma Hilo, a noho
they made their abode at iho la ma Kanokapa, kahi e pili
Kanokapa, a place adjoining the pu ana me ka nuku o ka muliwai
mouth of the Wailuku river, o Wailuku. E noho ana o
where lived a man by the name Kawaamaukele malaila, he
of Kawaamaukele, a great priest kahuna kakaolelo nui, ua
and counselor. He was a very elemakule oia, a poohina no hoi.
old man, his head was wholly Aka, he mea haohao nae ia ia
gray. Lonoikamakahiki i kona ike ana
aku i kela elemakule, no ka mea,
o kela kanaka ke kanaka ano e i
hiki mai i ke alo o
Keawenuiaumi, a ua loloa hoi
kona lauoho a hiki i lalo i ka
puhaka, e like mau me ke ano o
na kahuna nui.

When Lonoikamakahiki saw the A ike aku la o Lonoikamakahiki i


old man he was greatly ua elemakule nei, oiai e noho pu
surprised, because this man was ana oia me kona mau kahu.
the only man that differed from Ninau malu aku la: “He akua
the rest of the men that came in anei kela elemakule lauoho
the presence of Keawenuiaumi; loloa?” I aku la na kahu: “Aole he
his hair was so long that it akua, he kanaka no, he
reached below his waist, a thing kakaolelo nae, he kahuna nui oia
common with the high priests, ma na oihana kahuna apau.”
however. When Ninau hou aku la ua o
Lonoikamakahiki, who was Lonoikamakahiki: “Heaha ka
sitting with his attendants, had waiwai a ia elemakule?” I aku na
looked at the old man for some kahu: “O ke kanaka ike i ke
time he asked: “Is that old man kakaolelo, he kanaka nui ia imua
with the long hair a god?” The o ke alo alii; he kanaka akamai i
attendants replied: “He is not a ka olelo, ma kana olelo e olelo
god; he is a human being, but ai, malaila ke alii e hoolohe ai;
not of the ordinary kind; he is a nana e ike ka pomaikai o ka aina
counselor. He is also the high ame ke kanaka, he hiki i kela
priest, higher than all the others.” kanaka ke iki mai i ke kanaka
Again Lonoikamakahiki asked: waiwai ame ka waiwai ole, ke alii
“What is the old man good for?” waiwai ame ka waiwai ole.”
The attendants replied: “The
man who is a counselor is a very
great man in the court of the
king; he must be a man who is
skilful in language, and whatever
advice he gives the king, the
king will take heed. He can
predict the coming of prosperity
to the land and the people. That
man can tell whether a common
person will become rich or poor,
or the chief who will become
wealthy or not.”

When Lonoikamakahiki heard A lohe o Lonoikamakahiki i keia


these remarks from one of his olelo a ke kahu, he mea puiwa
retainers he was greatly loa ia nona, no kona lohe ana i
impressed that such a thing ka olelo, he hiki ke ike i ke alii
could be possible, that is, that waiwai, ame ka waiwai ole, a
the man could tell whether a nolaila, olelo aku la oia i kona
chief will become rich or poor. mau kahu, me ka i aku: “A, e ike
He therefore asked of his mai no auanei kela elemakule la
attendants: “And will that old ia’u?” I aku na kahuna: “Ae, aole
man be able to recognize me?” oe e nalo, a me kau hana
The attendants: “Yes, he will not mahope aku.” I hou aku la o
overlook you 12 and also your Lonoikamakahiki i na kahu: “He
doings in the future.” kanaka kapu anei kela, aole e
Lonoikamakahiki again asked kamailio ia aku e kamalii? O na
them: “Is there any restriction kanaka makua wale no anei?” I
placed on that man, that is, aku la na kahu: “Nau e kamailio
something that will prevent kela elemakule, i malamaia hoi
young people from addressing na kakaolelo ame na kahuna no
him? And are the grown up oukou no na ’lii.”
people the only ones that are
allowed to speak to him?” The
attendants replied: “You are
indeed privileged to address that
old man. Counselors and priests
are retained and cared for to be
used by the chiefs.”

Because of this Lonoikamakahiki A no keia mea hoouna aku la o


sent one of his attendants to go Lonoikamakahiki i kekahi kahu
and bring the aged counselor, ona e kii i ke kakaolelo ia
Kawaamaukele. When he came Kawaamaukele. A hiki mai la i
in the presence of mua o Keawenuiaumi me
Keawenuiaumi and Lonoikamakahiki, i aku la o
Lonoikamakahiki, Lonoikamakahiki: “I kiiia aku nei
Lonoikamakahiki spoke up oe no ko’u lohe ana he
saying: “You have been elemakule akamai oe i ka ike
requested to come here because mai i ke alii waiwai ame ka
I have been told that you are an waiwai ole; nolaila, e nana mai
old man who is learned in the oe ia’u, malia paha he alii ilihune
things of the future and can tell wau ma keia manawa aku, a e
whether a chief will become rich hai mai oe i ka’u mau hana
or poor; therefore I want you to [267]ma keia hope aku.” I mai o
make an examination of me and Kawaamaukele: “He alii waiwai
tell me what I am to be in the no oe i kekahi manawa, aia a
future.” [266]Kawaamaukele then hike aku i kou wa kanaka
replied: “You are going to be a makua, alaila, ilihune oe aole ou
wealthy chief at times, but when kanaka, aka, he alii koa oe.” I
you reach maturity then you will hou aku la o Lonoikamakahiki: “I
become poor, in that you will be aha ka’u hana e hana ai i waiwai
without followers; but you are ai? A ina ua ike oe i ka hana
going to be a brave chief.” waiwai no’u, alaila, e ao no
Lonoikamakahiki then again kaua.” Noho ke kahuna a liuliu
asked him: “What profession me ke kali ana i kona manawa e
shall I take up in order that I may olelo mai ai ia Lonoikamakahiki,
become wealthy? If you know alaila, olelo aku la: “O ka hana e
what I can take up that will be kaulana ai oe a puni na moku, o
profitable as a profession, then ke kakaolelo, ame ka hoopapa;
we will take it up and you instruct ina e akamai oe ma na hana
me in its detail.” The priest hoopapa, alaila, waiwai oe.” Ma
paused for a while, thinking of ka olelo a ke kahuna kakaolelo,
what Lonoikamakahiki had hoolohe aku la no o
asked, and then replied: “The Lonoikamakahiki.
professions that will make you
famous all over the islands are
that of a counselor and
hoopapa. 13 If you can be an
expert in this profession of
hoopapa, then you will become
wealthy.” Lonoikamakahiki took
to heart every word spoken by
the high priest.

Sometime after this the Mahope iho oia manawa, ao ae


profession of hoopapa was taken la oia i ka oihana hoopapa ma
up by Lonoikamakahiki and he ka aoao kakaolelo, a naauao oia
was educated into the different ma ia hana, a oia ka oihana i
things of the profession kaulana nui ai o
pertaining to that portion relating Lonoikamakahiki a puni na
to language, and after he had moku, o ke kolu no hoi ia o ka
mastered it he in later years did Lonoikamakahiki mau hana
become famous all over the akamai a hiki i kona make ana; a
islands. This made the third thing nui loa ka pilikia o kekahi poe alii
that Lonoikamakahiki became iaia.
proficient in up to the time of his
death, and he caused no end of
trouble for certain chiefs.

After completing the study of Mahope mai o kona ao ana i ka


hoopapa in Hilo he returned with oihana hoopapa ma Hilo, hoi aku
his parents to Napoopoo, where la oia me kona mau makua a
they took up their residence and noho ma Napoopoo, a hoomaka
he immediately practiced his aku la oia i ka hoopapa me na
profession on his playmates, and hoa paani ona, a lilo iho la ka
in this manner he made practical hana hoopapa i mea makemake
use of it. In this way the nui na Lonoikamakahiki a pau ka
profession of hoopapa became a la, a pela aku. Aka, o
favorite thing with him, making Lonoikamakahiki, ua
use of it day after day. After a hoolawehala wale aku oia i kona
time, however, Lonoikamakahiki mau hoa paani, i mea e hoopapa
began to ensnare his playmates ai, he mea e hoao ai i kana
by getting into argument with oihana hoopapa. O na puulu
them in order to test his kamalii a pau o Kealakekua, ua
profession of wrangling. All the hoopapa mau ia e
crowds of children in Kealakekua Lonoikamakahiki, aka nae, aole i
were taken up by ike o Lonoikamakahiki i kona
Lonoikamakahiki and defeated. akamai ma ia hana hope ana i
In thus making practical tests of ao ai, aka, o ka mea nana i ao
his vocation Lonoikamakahiki, aku, ua ike aku oia i ke akamai
although making great headway, ma ka hoopapa ana.
was at the same time unaware of
his advance in his profession;
but the person who had charge
of his education was well aware
of his skill in argument.

When Lonoikamakahiki grew to Ma ko Lonoikamakahiki mau la


the age of maturity he took unto hookanaka makua, lawe ae la
himself his cousin Kaikilani to be oia i kona kaikuahine ia Kaikilani
his wife. During the early part of i wahine nana. Mai ia manawa
their married life they lived in mai, he pono wale no ko laua
peace and happiness, and noho aua, aole i loaa ia laua ka
nothing occurred between them mea ino ma ko laua noho pu
to cause any dissatisfaction. ana. Iloko o ko laua manawa i
During all the time that they lived noho ai, aole i loaa keiki laua a
as man and wife they did not hiki i ko laua make ana. Aka, o
have issue; but Kaikilani had Kaikilani ka mea i hanau na keiki
three children with ekolu me kekahi mea e ae me
Kanaloakuaana, an uncle of Kanaloakuaana, he makuakane
Kaikilani’s. When no no ua o Kaikilani. Ia ike ana o
Kanaloakuaana took Kaikilani to Kanaloakuaana me Kaikilani,
be his wife their issue was loaa o Kalanioumi ame
Kalanioumi and Kealiiokalani, Kealiiokalani, he mau
who were girls, and Keakealani, kaikamahine laua, a o
a boy. Keakealani, ke keikikane.

Before Keawenuiaumi died he Mamua o ko Keawenuiaumi


requested Lonoikamakahiki to make ana, kauoha ae la oia ia
take the head of the government, Lonoikamakahiki e noho ma ka
but Lonoikamakahiki did not noho alii, aka, aole pela ko
think it proper to do so. What Lonoikamakahiki manao. O ko
Lonoikamakahiki told his father Lonoikamakahiki manao i olelo
was, that he did not wish to take aku ai i kona makuakane, aole
charge of the affairs of state at ona makemake e ku koke i ka
that time, but to defer the time moku, aia a makaukau oia ma
until he was able to master the na mea kaua, a ailolo hoi, alaila,
arts of warfare, when he could ku i ka moku. A nolaila, hooili ae
become expert therein; then he la o Keawenuiaumi i ka aina a
would take charge. Because of puni o Hawaii no Kaikilani. A
this, Keawenuiaumi left the make aku la o Keawenuiaumi,
whole island of Hawaii in the ku ae la o Kaikilani i ka moku,
care of Kaikilani. 14 After the oia ka wahine alii i ai i ka moku.
death of Keawenuiaumi, [269]
Kaikilani took charge of the
government. She was the first
chiefess who became the ruler of
the land. [268]

After Kaikilani had assumed the Ma ia hope mai o ko Kaikilani ai


care of the government, moku ana, kaapuni ae la o
Lonoikamakahiki made a circuit Lonoikamakahiki ia Hawaii a
of the island of Hawaii making puni, e hoiki ana i kona ike ma
public competitions in all the na mea ana i ao ai o ka oihana
different arts of warfare kaua, a lanakila ae ia oia ma ia
mastered by him, in which he mau hana. Aka, kui aku la keia
was always victorious. Word of mau hana a Lonoikamakahiki a
these accomplishments of lohe o Kanaloakuaana; a i ka hoi
Lonoikamakahiki was in time ana aku o Lonoikamakahiki mai
carried to the hearing of kana huakai kaapuni aku,
Kanaloakuaana. When hoomaka ae la oia i ka
Lonoikamakahiki arrived home mokomoko me Kanaloakuaana,
after making this circuit, he no ka mea, he akamai oia i na
competed in boxing against oihana kaua a pau. Aka, i mea e
Kanaloakuaana, for he, too, was ike ai o Kanaloakuaana i ke
skilful in all the arts of warfare. akamai o Lonoikamakahiki,
Kanaloakuaana did not demand nolaila, hoao hou laua i ka
this competition for any other mokomoko. Alaila, hoao aku la
purpose than to test for himself no o Kanaloakuaana ma ka oo
how proficient Lonoikamakahiki ihe; i aku o Lonoikamakahiki:
was, therefore they tried at “Aole wau i ao i ka oo ihe, aka, o
boxing and Kanaloakuaana ka alo ihe ka’u mea i ao.” A hoao
found that he was skilful. laua i ka alo ihe, ia
Kanaloakuaana then took up Kanaloakuaana nae ka ihe, o ka
spear throwing as the next thing. alo ka Lonoikamakahiki; ia hoao
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like