Ebook banner rotater for Web Programming and Administration

Visual J++

U N L E A S H E D

Bryan Morgan, et al.


CONTENTS

Introduction

Chapter 1   Visual J++: What It Is and Why It Is Unique

Chapter 2   The Visual J++ Development Environment

Chapter 3   Object-Oriented Programming with Java

Chapter 4   Understanding the Java Base Platform

Chapter 5   Elements of the Java Language

Chapter 6   Creating Programs with Java

Chapter 7   Advanced Java Programming

Chapter 8   Developing Applets and Applications

Chapter 9   Managing Visual J++ Projects

Chapter 10   The Visual J++ Compiler

Chapter 11   Building a Simple Java Applet with Visual J++

Chapter 12   Debugging with the Visual J++ Debugger

Chapter 13   The Standard Java Packages

Chapter 14   An Introduction to GUI Programming

Chapter 15   GUI Development Using the Visual J++ Resource Wizard

Chapter 16   Java and the Component Object Model

Chapter 17   Encapsulating COM with the Visual J++ Class Library

Chapter 18   The Microsoft Java Virtual Machine

Chapter 19   Extending Java Using ActiveX

Chapter 20   Calling COM Objects from Java

Chapter 21   Building COM Objects with Java

Chapter 22   Using ActiveX Documents to Convey Information

Chapter 23   Security with ActiveX Authenticode

Chapter 24   Distributed Component Object Model

Chapter 25   Browser Support for Active Content

Chapter 26   HTML and Web Page Design

Chapter 27   Manipulating Web Components Using JavaScript

Chapter 28   Manipulating Web Components Using VBScript

Chapter 29   Embedding Components Within Web Pages

Chapter 30   Querying Databases with Data Access Objects

Chapter 31   Basic Java Multimedia Capabilities

Chapter 32   Extending Multimedia Capabilities Through ActiveX

Appendix A   JavaScript Language Reference

Appendix B   VBScript Language Reference

Credits


Copyright© 1997 by Sams.net Publishing

FIRST EDITION

All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams.net Publishing, 201 W. 103rd St., Indianapolis, IN 46290.

International Standard Book Number: 1-57521-161-0

HTML conversion by :
    M/s. LeafWriters (India) Pvt. Ltd.
    Website : http://leaf.stpn.soft.net
    e-mail : leafwriters@leaf.stpn.soft.net

Trademarks

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams.net Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Visual J++ is a trademark of Microsoft Corporation.


Publisher and PresidentRichard K. Swadley Publishing ManagerGreg Wiegand
Director of Editorial ServicesCindy Morrow Managing EditorKitty Wilson Jarrett
Director of MarketingJohn Pierce Assistant Marketing ManagersKristina Perry, Rachel Wolfe
Acquisitions EditorSharon Cox Development EditorJeffrey J. Koch
Software Development Specialist Brad MyersProduction Editor Kitty Wilson Jarrett
Copy EditorsKimberly K. Hannel, Marilyn J. Stone, June Waldman
IndexerTom Dinse Technical ReviewerGreg Guntle
Editorial CoordinatorKatie Wise Technical Edit CoordinatorLynette Quinn
Resource CoordinatorDeborah Frisby
Editorial AssistantsCarol Ackerman, Andi Richter, Rhonda Tinch-Mize Cover DesignerTim Amrhein
Book DesignerGary Adair Copy WriterPeter Fuller
Production Team SupervisorBrad Chinn
ProductionJenaffer Brandt, Sonja Hart, Brad Lenser, Chris "Bud" Livengood

Acknowledgments

Special thanks go out to the following people, without whom this book would have been much, much more difficult to complete: Sharon Cox, Chris Denny, Jeff Koch, Kitty Wilson Jarrett, Mike Nygard, David Blankenbeckler, Vince Mayfield, and Jeff Perkins. Also thanks to TASC for providing a work environment in which special projects outside of work are encouraged and appreciated.

Dedication

This book is dedicated to my wife, Becky, and our beautiful new baby who hasn't entered the world yet. Thank you both for allowing me to share my hopes and dreams with you.

-Bryan Morgan

About the Authors

Bryan Morgan

Bryan Morgan is a software engineer with TASC, Inc., in Fort Walton Beach, Florida. He holds a bachelor's degree in electrical engineering from Clemson University and has also authored material for several other books by Sams.net Publishing, including Java Developer's Reference. Bryan and his wife, Becky, are anxiously awaiting the arrival of their first child in November 1996.

David Blankenbeckler

David Blankenbeckler received a bachelor of science degree in electrical engineering from Clemson University in 1991. After graduation, David worked for AT&T's Workstation Products Division as the primary software engineer for AT&T notebook products. David moved to Oregon in 1995 to work for Intel Corporation as a senior software engineer. His programming experience includes Java, C/C++, JavaScript, VBScript, HTML, Visual Basic, and Delphi. David currently lives in Oregon with his wife, Kimberly, and new son, Logan.

Mike Cohn

Mike Cohn is the director of information technology at Access Health, Inc., the leading provider of personal health management. Before that he was with Andersen Consulting and the Adler Consulting Group in New York. He holds a master's degree in computer science from the University of Idaho and has been programming for 16 years. Mike lives in Cameron Park, California, with his wife, Laura, and their daughter, Savannah.

David Hanley

David Hanley is a professional Java programmer working out of Chicago, where he was born. He is currently completing his master's degree in computer science. When he is not working or studying, he enjoys running, bicycling, martial arts, playing chess, or relaxing with a book.

Mahendra Palsule

Mahendra Palsule is a software professional born and raised in Mumbai, India. With an engineering diploma in computer technology from Bombay in 1991, he is also a Microsoft Certified Professional in Windows Operating Systems Services & Architecture. He has worked as a software consultant for the past four years, and has experience in software development, networking, and multimedia authoring on Windows and Macintosh platforms. He has contributed to multimedia projects in Europe and the Middle East. He is currently involved in Web Publishing at Radan Multimedia Limited, Mumbai. Apart from his obsession with computers and the Internet, he has diverse interests from astronomy to epistemology. He loves to work on multimedia projects where he can synthesize his creative and technical skills. You can reach him at mahendra@radanmedia.com.

Hiro Ruo

Hiro Ruo was born in Taichung, Taiwan. He has lived in Tokyo, Japan, and did most of his growing up in Skokie, Illinois (a suburb of Chicago). Hiro received a bachelor of science degree in electrical engineering from Northwestern University and a master of science degree in electrical engineering from Purdue University. He worked for more than five years at NCR (eventually AT&T, and back to NCR). Currently, he is a software engineer with Intel Corporation.

Mark Seminatore

Mark Seminatore has a master's degree in mechanical engineering and has been programming for more than 15 years. When not programming killer Java applets, Mark likes to work on high-performance graphics and optimization. Mark was one of the co-authors of Tricks of the Game-Programming Gurus and More Tricks of the Game-Programming Gurus. Mark has also written several articles for Dr. Dobb's Journal, including "A Raycasting Engine in C++" and "A 2D Gaming Engine in C." He can be reached via the Internet at 72040.145@compuserve.com.

Tell Us What You Think!

As a reader, you are the most important critic and commentator of our books. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can help us make strong books that meet your needs and give you the computer guidance you require.

Do you have access to CompuServe or the World Wide Web? Then check out our CompuServe forum by typing GO SAMS at any prompt. If you prefer the World Wide Web, check out our site at http://www.mcp.com.

NOTE
If you have a technical question about this book, call the technical support line at 800-571-5840, ext. 3668.

As the publishing manager of the group that created this book, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn't like about this book-as well as what we can do to make our books stronger. Here's the information:
Fax:317-581-4669
E-mail:programming_mgr@sams.mcp.com
Mail:Greg Wiegand
Publishing Manager
Sams.net Publishing
201 W. 103rd Street
Indianapolis, IN 46290


Introduction

Visual J++ is the name of Microsoft's Java development tool. Using Visual J++, you can create powerful applets and embed them within a Web page for distribution across the Internet or a local intranet. In addition, standalone applications can be written in Java that can run on any operating system that supports the Java Virtual Machine. If Microsoft had stopped here, Visual J++ would probably be noted for its excellent integrated development environment (IDE) and its extremely fast compiler.

However, Microsoft also extended the Java Virtual Machine and Visual J++ to support the integration of Java with the Microsoft object model, the component object model (COM). Tools included with Visual J++ allow Java objects to call ActiveX objects and, likewise, ActiveX objects can call Java objects. In fact, it is even possible to create a COM object in Java. This is important to the Java developer because of the huge installed base of COM objects already existing in the form of OLE objects and OCX or ActiveX controls. In short, Visual J++ allows the Java developer to truly choose the best tool for the job at hand, whether that tool be ActiveX or Java.

It is important to remember that pure Java bytecodes produced by the Visual J++ compiler will run unmodified in any Java-enabled browser on any platform. Therefore, the majority of the focus of this book is on building traditional Java applications. Specific topics that are examined in this book are

Throughout this book, examples are given to illustrate relevant topics. The majority of these examples are included on the CD-ROM accompanying this book and can be compiled and run unmodified using Visual J++.

Conventions Used in This Book

TIP
Tips appear in text blocks like this; they give hints and ideas for how to use Visual J++.

NOTE
Sections like this identify noteworthy features or highlight key points being covered in the text. This draws your attention to something that should not be overlooked.

A Warning box cautions you against making a mistake you could make either by overlooking an important step or by doing something that you might otherwise try to do. A mistake here could cause problems later.

Text that you type and text that should appear on your screen is presented in monospace type:


It will look like this to mimic the way text looks on your screen.

Placeholders for variables and expressions appear in monospace italic.

How to Use This Book

This book contains introductory information that will be of interest to the beginning Java developer as well as a large amount of advanced information that is designed to help intermediate to advanced Java programmers. Although the focus of this book is on Visual J++, the majority of the topics in this book provide technical information of interest to the Web developer such as Java, ActiveX, and VBScript/JavaScript. Therefore, anyone interested in building interactive Web applications using the latest technologies should find this book to be an invaluable resource.

Visual J++ Unleashed introduces and thoroughly examines Microsoft's exciting new Java development tool: Visual J++. Due to the capabilities of Visual J++, Web programming techniques using Java, ActiveX, VBScript, and JavaScript are examined in great detail. In addition, useful sample programs are given in each chapter to illustrate the power of these technologies.

For readers new to the Java language, the book begins with an introduction to Java programming fundamentals in Part I, "Introduction to Java Programming Using Visual J++." Special attention is given to object-oriented programming with Java and advanced Java programming topics such as multithreading, exception handling, and networking.

Following this introduction to the Java language, the Visual J++ development environment is examined in Part II, "The Visual J++ Development Tools." Visual J++ includes a powerful integrated development environment, Microsoft's Developer Studio, and a number of time-saving wizards and programming tools.

Because the Microsoft Java Virtual Machine included with Visual J++ and Microsoft's Internet Explorer browser supports the integration of ActiveX controls and Java applets, ActiveX and its underlying technology COM are explained in Part III, "The Foundation for Visual J++: The Component Object Model." This part of the book explains COM and ActiveX in great detail and focuses on building Web-based applications using Java and ActiveX. Interesting examples are given each step of the way to help explain these critical technologies.

Because much of the growth in popularity of the Java language can be attributed to its use to build applets for display within Web pages, Part IV, "Activating the Internet with Visual J++," focuses on Web programming topics. Included in this section are chapters that compare the capabilities of popular Web browsers, explain the latest versions of HTML, and illustrate the construction of active Web pages using VBScript and JavaScript.

Part V, "Visual J++ Development Topics," focuses on real-world Java programming issues. Included in this section are chapters on network programming, database access using JDBC, Microsoft's Data Access Objects, and multimedia programming with Java.