Java Studio Creator Field Guide 2nd Ed 2004.pdf

(27200 KB) Pobierz
intro.fm
J AVA TM S TUDIO
F IELD G UIDE
S ECOND E DITION
3269463.002.png
J AVA T ECHNOLOGY
O VERVIEW
Topics in This Chapter
• The Java Programming Language
• JavaBeans Components
• NetBeans Software
• The XML Language
• The J2EE Architecture
• JavaServer Faces Technology
• JDBC and Databases
• Ant Build Tool
• Web Services
• EJBs and Portlets
3269463.003.png
Chapter
elcome to Creator! Creator is an IDE (Integrated Development
Environment) that helps you build web applications. While many
IDEs out in the world do that, Creator is unique in that it is built on
a layered technology anchored in Java. At the core of this technol-
ogy is the Java programming language. Java includes a compiler that produces
portable bytecode and a Java Virtual Machine (JVM) that runs this byte code on
any processor. Java is an important part of Creator because it makes your web
applications portable.
But Java is more than just a programming language. It is also a technology
platform . Many large systems have been developed that use Java as their core.
These systems are highly scalable and provide services and structure that
address some of the high-volume, distributed computing environments of
today.
1.1 Introduction
Creator depends on multiple technologies, so it’s worthwhile touching on them
in this chapter. If you’re new to Java, many of its parts and acronyms can be
daunting. Java technologies are divided into related packages containing
classes and interfaces. To build an application, you might need parts of one sys-
tem and parts of another. This chapter provides you with a road map of Java
3
W
3269463.004.png
4
Chapter 1 Java Technology Overview
technologies and documentation sources to help you design your web applica-
tions with Creator.
We’ll begin with an overview of the Java programming language. This will
help you get comfortable writing Java code to customize your Creator applica-
tions. But before we do that, we show you how to find the documentation for
Java classes and methods. This will help you use them with confidence in your
programs.
Most of the documentation for a Java Application Program Interface (API)
can be accessed through Creator’s Help System, located under Help in the
main menu. Sometimes all you need is the name of the package or the system
to find out what API a class, interface, or method belongs to. Java consists of
the basic language (all packages under java ) and Java extensions (all packages
under javax ). Once you locate a package, you can explore the interfaces and
classes and learn about the methods they implement.
You can also access the Java documentation online. Here’s a good starting
point for the Java API documentation.
http://java.sun.com/docs/
This page contains links to the Java 2 Platform Standard Edition, which con-
tains the core APIs. It also has a link to all of the other Java APIs and technolo-
gies, found at
http://java.sun.com/reference/docs/index.html
Creator is also built on the technology of JavaServer Faces (JSF). You can
find the current JSF API documentation at
http://java.sun.com/j2ee/javaserverfaces/1.0/docs/api/
index.html
JSF is described as part of the J2EE Tutorial, which can be found at
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
These are all important references for you. We’ve included them at the
beginning of this book so it’s easy to find them later (when you’re deep in the
challenges of web application development). For now, let’s begin with Java as a
programming language. Then we’ll look at some of the other supporting tech-
nologies on which Creator is built.
3269463.005.png
1.2 The Java Programming Language
5
1.2 The Java Programming Language
This cursory overview of the Java programming language is for readers who
come from a non-Java programming environment. It’s not meant to be an in-
depth reference, but a starting point. Much of Creator involves manipulating
components through the design canvas and the components’ property sheets.
However, there are times when you must add code to a Java page bean (the
supporting Java code for your web application’s page) or use a JavaBeans com-
ponent in your application. You’ll want a basic understanding of Java to more
easily use Creator.
Object-Oriented Programming
Languages like C and Basic are procedure-oriented languages, which means
data and functions are separated. To write programs, you either pass data as
arguments to functions or make your data global to functions. This arrange-
ment can be problematic when you need to hide data like passwords, customer
identification codes, and network addresses. Procedure-oriented designs work
fine when you write simple programs but are often not suitable to more com-
plex tasks like distributed programming and web applications. Function librar-
ies help, but error handling can be difficult and global variables may introduce
side effects during program maintenance.
Object-oriented programming, on the other hand, combines data and func-
tions into units called objects . Languages like Java hide private data ( fields ) from
user programs and expose only functions ( methods ) as a public interface. This
concept of encapsulation allows you to control how callers access your objects. It
allows you to break up applications into groups of objects that behave in a sim-
ilar way, a concept called abstraction . In Java, you implement an object with a
Java class and your object’s public interface becomes its outside view . Java has
inheritance to create new data types as extensions of existing types. Java also
has interfaces, which allow objects to implement required behaviors of certain
classes of objects. All of these concepts help separate an object’s implementa-
tion (inside view) from its interface (outside view).
All objects created from the same class have the same data type. Java is a
strongly typed language, and all objects are implicitly derived from type
Object (except the built-in primitive types of int , boolean , char , double ,
long , etc.). You can convert an object from one type to another with a converter.
Casting to a different type is only allowed if the conversion is known by the
compiler. Creator’s Java editor helps you create well-formed statements with
dynamic syntax analysis and code completion choices. You’ll see how this
works in Chapter 2.
Error handling has always been a tough problem to solve, but with web
applications error handling is even more difficult. Processing errors can occur
3269463.001.png
Zgłoś jeśli naruszono regulamin