Introduction

It doesn’t take a rocket scientist to notice the recent serious decline in the publishing of computer books, to say nothing of computer magazines. I enjoy reading books about software and visit the nearby Barnes and Noble at least twice a month. During the last three years the number of bookcases dedicated to computer books has shrunk substantially.

Today newly baked programmers prefer Google to books. They don’t realize that Google is OK when you know what you are looking for, while books can give you a new perspective on how other people develop software.

During a recent visit to a major bookstore I noticed a series of books on digital photography. I’m one of the legions of people who are thinking of replacing a point-and-shoot camera with a digital SLR such as a Nikon D90. There were about 10 different thin books on that shelf, and I picked the one on the D90. It was about 65 pages long. I quickly skimmed the pages, learning that compared to a pocket camera one of the main advantages of D-SLR is the ability it gives you to change lenses. On top of that, these cameras use a small mirror that enables you to see exactly what you’re shooting, plus you can take more shots per second. Not much information for a $25 book.

The secret was that the book came with a DVD, which contained 80 minutes of instructional videos! The printed part of the book and the DVD complemented each other. The wannabe photographers don’t want to read books.

The new generation of computer programmers doesn’t want to read either. They want to watch videos. They can be YouTube videos on how to do something, or screencasts. The material has to be prepared for easy consumption.

But because not everything in the world of software can be videotaped, future computer books will still include several hundred pages — some code samples and short instructions will go there.

Remember those 1,500-page Bibles on software? It seems that their days are over. These days a 500-page computer book can be considered thick. Five years from now a 200-page software book will become the standard. But books will come with DVDs on which the authors walk you through all the examples mentioned on paper.

I like this new 24-Hour Trainer series from Wiley Publishing. This is not to say that you can learn the software covered in these books within 24 hours. It’s about having a trainer that’s with you 24 hours a day. Each book in this series is a set of short chapters containing a minimum of theory but accompanied by an instructional DVD with screencasts recorded by the author.

Who This Book Is For

This book is for anyone who wants to learn how to program with the Java language. No previous programming experience is expected.

This tutorial can be used by Java developers looking for simple working examples that use certain features of the language.

Accomplished Java developers can also use this book as a refresher while preparing for a technical job interview.

This tutorial can be used by university students who are interested in learning from a practitioner who has spent 20-plus years developing enterprise software for a living.

College professors should appreciate the fact that each lesson ends with a “Try It” section — a prepared home assignment for each lesson.

What This Book Covers

To be called a Java developer, a person has to know not only the core syntax of this programming language, but also the set of server-side technologies called Java EE (Enterprise Edition). This book covers both. At the time of this writing, the latest version of core Java is 6, and the latest release of Java EE is also 6.

Java is a general-purpose language — you can program applets running under control of a Web browser, stand-alone applications that run independently on the user’s computer, and applications that connect to remote servers. Java is used for writing applications running in mobile devices, cars, or in household appliances.

The first 25 lessons of this book cover a program that can run on users’ computers. The next 12 are about Java EE technologies used for Java programs that run on servers. The final lesson is dedicated to the process of getting prepared for Java technical job interviews.

This book doesn’t cover Java programming for mobile devices.

How This Book Is Structured

This book is a tutorial. Each lesson walks you through how to use certain elements and techniques of the Java language or gives an introduction to the server-side Java EE technologies. The “Try It” sections serve as continuations of materials explained in the lessons. The screencasts included on the DVD usually illustrate how the author compiles and runs code samples included in the lessons. You can choose to read the lesson and then try to run the example on your own, or you can read the lesson, watch the video, and then try to run the examples. After this part is done, start working on the assignments from the “Try It” section.

This book contains 38 lessons, which are not formally broken into sections. The first 25 lessons cover Java SE topics. Lessons 26 through 34 cover Java EE topics. Lessons 35 and 36 introduce you to popular third-party frameworks Spring and Hibernate. Lesson 37 demonstrates an application that utilizes several Java EE technologies. And, finally, Lesson 38 helps you to get prepared for the technical interview when you decide to look for a Java-related job.

The lessons are short and to the point. The goal is to explain the material quickly so you can start applying it hands-on as soon as possible. Some readers may feel that more explanation of certain subjects are required, and they are encouraged to do some extra research; there are lots and lots of online materials available on any Java-related subject. But the coverage of the material given in this book definitely helps in understanding what to focus on and what to look for.

What You Need to Use This Book

To do the examples in this book, you do not need to purchase any software—freely available software is used here. Installing Java Development Kit and Eclipse IDE is explained in the first two lessons, and this is all you need for Lessons 1 through 25. In Lesson 26, you install Java Application Server GlassFish, which is used for explanation of the materials in Lessons 26 through 34. If you decide to learn third-party frameworks Spring and Hibernate, you need to download and configure their software libraries as explained in Lessons 34 and 35. Whenever you need to download certain software, detailed instructions are given in the book and/or in the screencasts included on the DVD.

From the hardware perspective, you can use either PC running Windows or one of the Apple computers running Mac OS. Linux fans are also able to run all book samples. You should have at least 1GB of RAM on your computer to run all code examples from this book. But adding more memory can make your Java compiler and Eclipse IDE work faster.

How to Read This Book

This book is a tutorial, and I assume in each lesson that the reader is already familiar with the materials from those that came before it. If you are new to Java, I highly recommend that you read this book sequentially.

Each lesson except the last one has a corresponding video screencast on the accompanying DVD, in which I either work on the assignment from the “Try It” section of the lesson or simply install and configure some software. Ideally, you should try to do all the assignments from the “Try It” sections on your own, and use the videos only if you get stuck or don’t understand the instructions. But if you prefer to learn by following the instructor, just watch the video first and then try to repeat the same actions on your own. Whatever works is fine.

Java is a multi-platform language and programs written for Microsoft Windows, say, should work the same way in Mac OS or on Linux computers. I’m using a Mac, but also have special software that enables me to run Microsoft Windows. In this book I use the open-source Eclipse Integrated Development Environment, which exists on all major platforms and looks pretty much the same on each. So regardless of your preferred operating system, you’ll be able to run all the code samples from this book.

Conventions

To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book.

note.ai

Notes, tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.

cd.ai

References like this one point you to the DVD or www.wrox.com to watch the instructional video that accompanies a given lesson.

As for styles in the text:

  • We highlight new terms and important words when we introduce them.
  • We show file names, URLs, and code within the text like so: persistence.properties.
  • We present code like the following:
    We use a monofont type with no highlighting for most code examples.
    

Source Code

As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All of the source code used in this book is available for download at www.wrox.com. You will find the code snippets from the source code are accompanied by a download icon and note indicating the name of the program, so you know it’s available for download and can easily locate it in the download file. Once at the site, simply locate the book’s title (either by using the Search box or by using one of the title lists) and click the Download Code link on the book’s detail page to obtain all the source code for the book.

download.eps

Listings include the filename in the title. If it is just a code snippet, you’ll find the filename in a code note such as this:

Code Filename
note.ai

Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-0-470-88964-0.

After you download the code, just decompress it with your favorite compression tool. Alternately, you can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.

The author will also maintain up-to-date code samples in the code repository hosted by Google at the following address: http://code.google.com/p/practicaljava/.

This website also contains a sample online store application contributed by Nick Golubyev. Even though this application was not used in the book, it serves as a good example of an end-to-end application developed with Java EE 6 technologies. You can find the application by clicking the Source tab in the folder java-ee. You can find instructions on building the online store under the tab Wiki.

Errata

We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save another reader hours of frustration, and at the same time you will be helping us provide even higher quality information.

To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all errata that has been submitted for this book and posted by Wrox editors. A complete book list including links to each book’s errata is also available at wrox.com/misc-pages/booklist.shtml.

If you don’t spot “your” error on the Book Errata page, go to wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We’ll check the information and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the book.

p2p.wrox.com

For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

At p2p.wrox.com you will find a number of different forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:

1. Go to p2p.wrox.com and click the Register link.

2. Read the terms of use and click Agree.

3. Complete the required information to join as well as any optional information you wish to provide and click Submit.

4. You will receive an e-mail with information describing how to verify your account and complete the joining process.

note.ai

You can read messages in the forums without joining P2P but in order to post your own messages, you must join.

Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

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

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