oracle jdeveloper oracle jdeveloper log: log: …978-1-4302-0706-1/1.pdforacle jdeveloper log:...

12
Oracle JDeveloper lOg: Empowering J2EE Development HARSHADOAK ApreSS"' Oracle JDeveloper lOg: Empowering J2EE Development HARSHAD OAK APress Media, LLC

Upload: truongthien

Post on 02-May-2018

254 views

Category:

Documents


2 download

TRANSCRIPT

Oracle JDeveloper lOg: Empowering J2EE

Development HARSHADOAK

ApreSS"'

Oracle JDeveloper lOg: Empowering J2EE

Development HARSHAD OAK

APress Media, LLC

Oracle JDeveloper 1og: Empowering J2EE Development Copyright 02004 by Harshad Oak Origlnally published by Apress 2004

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying. recording. or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.

ISBN 978-1-59059-142-0 ISBN 978-1-4302-0706-1 (eBook) DOI 10.1007/978-1-4302-0706-1

Thademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

Technical Reviewer: Kenneth Cooper Jr.

Editorial Board: Steve Anglin, Dan Appleman, Gary Comell, James Cox, Tony Davis, John Franklin, Chris Mills, Steven Rycroft, Dominic Shakeshaft, Julian Skinner, Martin Streicher, Jim Sumser, Karen Watterson, Gavin Wray, John Zukowski

Assistant Publisher: Grace Wong

Project Manager: Thacy Brown Collins

Copy Editor: Kim Wunpsett, Brian MacDonald

Production Manager: Kari Brooks

Production Editor: JanetVail

Proofreaders: Elizabeth Barry and Patrick Vmcent

Compositor: Kinetic Publishing Services, LLC

Indexer: Valerle Perry

Cover Designer: Kurt Krames

Manufacturing Manager: Tom Debolski

The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or darnage caused or alleged to be caused directly or indirectly by the information contained in this work.

To my wonderful parents, Aai and Baba

Contents at a Glance

Foreward ........................................................... . xi

About the Author ................................................. xiii

About the Technical Reviewer ..................................... xv

Acknowledgments .................................................. xvii

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Emergence of the IDE ................................ 1

Getting Started with JDeveloper ................... 9

Java with JDeveloper ............................... 17

UML Model:i,ng ........................................ 57

Servlet and JSP Development ....................... 75

Enterprise JavaBeans and Database

Interaction ........................................ 117

Application Development Framewerk ............... 151

Web Services ....................................... 183

Debugging and Code Improvement .................. 207

Tools and Extensions .............................. 235

Tips and Tricks ................................... 251

Index .............................................................. 261

V

Contents

Foreward ........................................................... . xi

About the Author ................................................. xiii

About the Technical Reviewer ..................................... xv

Acknowledgments .................................................. xvii

Chapter 1 Emergence of the IDE ............................ 1

From Notepad to JDeveloper ........................................ 2 The IDE Alternatives ............................................. 3 Other Commonly Used !DEs .......................................... 5 The Rise of JDeveloper ............................................ 7 Summary .............................................................. 7

Chapter 2 Getting Started with JDeveloper ............. 9

Downloading JDeveloper ............................................. 9 Installing JDeveloper ............................................. 12 Summary ............................................................ . 16

Chapter 3 Java with JDeveloper ........................... 17

JDeveloper Documentation ......................................... 17 Understanding Workspaces and Projects .......................... 17 Using JDeveloper .................................................. 18 A Simple Java Application ........................................ 21 Developing a Java UI .............................................. 34 Summary ............................................................. 56

Chapter 4 UML Modeling ...................................... 57

Unified Modeling language ........................................ 57 Summary ............................................................. 74

vii

Contents

Chapter 5 Servlet and JSP Development ................. 75

Web Applications .................................................. 75 Serv lets ........................................................... 78 Embedded OC4J ...................................................... 88 Java Server Pages ................. : . .............................. 90 Jakarta Struts ................................................... 100 Deploy to a WAR File ............................................ 113 Summary ............................................................ 115

Chapter 6 Enterprise JavaBeans and Database Interaction ...................................... 117

Enterprise JavaBeans ............................................. 117 Interfaces ........................................................ 122 The Process ....................................................... 123 Bean Client ....................................................... 133 Using a Database ................................................. 137 Student Course Application ...................................... 139 Summary ............................................................ 149

Chapter 1 Application Development Framework ........ 151

Answering Key Questions ......................................... 151 What Is ADF? ...................................................... 152 Understanding the Components of ADF ........................... 153 ADF Business Components ......................................... 154 Introducing UIX .................................................. 170 Introducing JClient .............................................. 175 Deploying to JAR ................................................. 180 Summary ............................................................. 181

Chapter 8 Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

The Need for Web Services ...................................... . 183 Service-Oriented Architecture (SOA) ............................ 185 Web Services Technologies ....................................... 186 A Simple Java Web Service ....................................... 188 UDDI Browser ...................................................... 200 Summary ............................................................ 205

viü

Contents

Chapter 9 Debugging and Code Improvement ............ 207

Introducing the Tools ........................................... 207 Using the Debugger ............................................... 208 Debugging Web Applications ...................................... 217 UI Debugger ....................................................... 220 Introducing CodeCoach ............................................ 222 Introducing the Profilers ....................................... 225 Introducing the TCP Packet Monitor ............................. 232 Summary ............................................................ 234

Chapter 10 Tools and Extensions .......................... 235

Apache Ant ........................................................ 235 Source Control ................................................... 241 Extensions ........................................................ 244 Summary ............................................................ 249

Chapter 11 Tips and Tricks ................................ 251

The Tips .......................................................... 251 Keyboard Shortcuts ............................................... 258

Index ............................................................ . 261

ix

Foreword

JAVA HAS COME A LONG WAY since its birth in the mid-1990s and, as you will dis­cover in this book, so have Java development tools.

With the growth of the Java language comes an ever-increasing complexity of the platform. You need the power of an Integrated Development Environment (IDE) when you are dealing with vast amounts of technologies, Application Programming Interfaces (APis), code, and metadata.

Modern Java IDEs cover the entire development life cycle from design to deployment, including coding, debugging, tuning, testing, and controlling source. There is no Ionger a need to buy several different tools from several dif­ferent vendors to get the job done. This will save you time and money because you don't have to set up and maintain different environments or deal with mul­tiple vendors when you have an issue.

So, what's next for Java development tools? There are two major requirements that the tools need to address going forward. First, because you are dealing with so much code, the tools need to automate more of the programming work. This area of guided coding techniques includes features such as quick fix error detec­tion and correction, refactoring, code formatting, and other coding assistance features.

Second, the overall complexity of developing in Java is still very high, making the lan~age accessible mainly to expert programmers. This is where development frameworks come to the rescue by providing a more visual and declarative development environment, shielding you from the underlying complexities of the platform. This is similar to how Windows development became accessible to the masses after the introduction of frameworks such as Visual Basic, PowerBuilder, and Oracle Forms.

Oracle is marehing forward on both fronts with ]Developer lOg. The first installment of lOg introduces the Oracle Application Development Framework (ADF), and the second will address programmer productivity.

With this book, Harshad Oak has found the "sweet spot" for people planning to use Oracle JDeveloper. Whether you are evaluating JDeveloper or have recently decided to start developing with it, this book gives you everything you need to get up and running with the tool and explore the wide range of capabilities it offers.

Over the course of the book, you will become familiar with the JDeveloper IDE and learn about Java technologies such as Servlets, Java Server Pages, Enterprise JavaBeans, and Web Services. Harshad also introduces Oracle ADE For more infor­mation about the framework and other features of the product, you can turn to the Oracle Technology Network at http:// otn.oracle.com/products/jdev.

xi

Foreward

xii

I am convinced you will enjoy reading this book, and I hope you will get a chance to try out JDeveloper.

Roel Stalman Senior Director of Product Management, Application Development Tools Oracle Gorparation

About the Author

Harshad Oak has a master's degree in computer man­agement from Symbiosis, India, and is a Sun Certified Java Programmer and a Sun Certified Web Component Developer. He is the founder of Rightrix Solutions (http:/ /www.rightrix.com), which is primarily involved in software development and content management services. Harshad has been part of several J2EE proj­ects at i-flex Solutionsand Cognizant Technology Solutions. Furthermore, he has written several articles

about Java/J2EE for CNET Builder.com (http:/ /www.builder.com). Harshad also coauthored the book Java 2 Enterprise Edition 1.4 Bible (Wiley & Sons, 2003) and is currently working on a book about Jakarta Commons for Apress.

Harshad is passionate ab out all kinds of writing and has published articles on a wide array of subjects ranging from terrorism to wildlife. He is an avid nature Iover and enjoys reading nonfiction books. He hopes to retire as soon as possible to any sparsely populated place that provides just the basic necessities of life. A cutting-edge PC and a lightning fast Internet connection do, however, fall into the "basic necessities of life" category.

Feel free to send all comments and suggestions to [email protected].

xili

About the Technical Reviewer

Kenneth Cooper Jr., is a senior principal instructor with a major IT company in Silicon Valley. He has worked in the Javaarena for more than five years special­izing in the J2EE areas of Java technology and has worked with all versions of JDeveloper since its inception, as AppBuilder 1.0, approximately five years ago.

Prior to working in industry he was in academia where he taught computer science for 25 years. His areas of specialization were language theory, database systems, and operating systems.

He currently lives in the Bluegrass region of central Kentucky. He would like to dedicate his efforts to his wife, Patricia, for her support.

XV

Acknowledgments

THIS BOOK HAS BEEN a remarkable journey where so many people across conti­nents have played apart. Thanks for all the effort, time, and interest you all have put into this book. My thanks go out to Tracy for managing the project as a whole, to Doris for the marketing and book promotion, and to Steve for ensuring that the book stayed on course. Ken did a great job of the tech review, and John and Craig were responsible for giving initial direction to the book. Kim and Brian had the tough task of ironing out the language and structure of each chapter.

Thanks to Laura and Stacey at Studio B for being an important part of all my book assignments and always keeping author interests the top priority. Thanks to Roel for helping me with the book's content and for writing a foreward for the book.

You all are very, very special to me. Thanks a Iot. My family and friends have of course played a huge part in this book becoming

a reality. Thank you to Baba, Charu, Subodh, and Chinmay. Sangeeta had the not so enjoyable task ofhaving to read rough drafts of chapters and suggest changes. Thanks a Iot.

I also want to thank all the people through the ages who have worked toward spreading peace on the planet. These apostles of peace have ensured that human society does not crumble into anarchy. While the world keeps shrinking, we still seem to work so hard to hate and hurt fellow beings. We distinguish on religion, race, caste, creed, color, and whatnot. Are these things really so important? None of us chose our religion, caste, creed, color, or where and to whom we would be bom. We all are essentially good people capable of caring and loving. Piease give this a thought. We all need to exterminate this virus ofhate that is rapidly spread­ing across allhuman systems.

xvii