Introduction to Java Programming Training Class
With Symantec VisualCafe
This four-day Introduction to Java Programming training class teaches you the Java and JDBC programming skills you need to enhance your web pages with powerful Java aplets and build database-driven, Web-based applications.
Important Note: Although the course uses Symantec's award-winning Visual Cafe as the development tool, the Java language skills and debugging techniques taught in class are universally applicable.
The exciting topics you will explore in this course include:
- The Role of Java in Internet Development:
Java has been heralded as a revolutionary tool for building Internet and Intranet applications, but what is behind the hype? Through several brief case studies, you will learn practical uses for Java and what role the language plays in conjunction with HTML, CGI Scripts, JavaScript, and other Web development technologies. In addition, you will learn the fundamental differences between Java applets and applications.
- Object-Oriented Programming:
Java is an object-oriented programming language. As a result, applets and applications written in Java are structured very differently from programs written in C, Pascal, Perl, and other more procedural languages. You will learn key object-oriented programming concepts, such as classes and packages, class hierarchy and inheritance, encapsulation, methods, properties, interfaces and more. In addition, you will learn the key ways in which Java differs from C++
- Writing, Compiling and Debugging Java Applets:
Within the first 30 minutes of class, you will write and compile your first Java applet, debug it, and embed it within a Web page. Later, you will learn how to use Visual Café's debugging tools to debug even the most complex Java applications.
- Mastering the Java Packages:
The 300+ classes in the Java language are organized into more than 20 packages. The key to successfully programming in Java is knowing which packages to look in to locate the classes you need. During the course, you will master the basics of the most important Java packages: java.awt, java.applet, java.io, java.lang, java.net, and java.sql. Even more importantly, you will learn how to use Java in a Nutshell and your development tool's API reference to quickly look up and learn any packages and classes not directly covered in the course.
- Building Database Front-ends using Java and JDBC:
Java Database Connectivity (JDBC) enables you to build applets that can communicate directly with a database. During the fourth day of class, which focuses exclusively on JDBC, you will learn the fundamentals of JDBC and will build interfaces that enables users to search, select, edit, and delete records in a database.
- Introduction to JavaBeans:
JavaBeans enable you to convert components (pieces of programs) that you have written in Java into "beans," which can be easily reused in other applets and applications. You will learn the fundamentals of JavaBeans and will build a bean for connecting to a database. This bean will substantially shorten the time it takes to build a database-driven applet or application.
- Java Applet-CGI Script Interaction:
Using WestLake Internet Training's Applet-to-CGI class (available for your use after the class via download from WestLake's Web site), you will learn how to build a form in Java that can submit data to a backend CGI script or Active Server Page (ASP). This script or ASP, in turn, could send an email message based on the information the user enters in the form or use this information to search a database.
- Threads in Java:
You will learn how to "multi-thread" your Java applets and applications. Threads enable parts of a Java program's code to be executed in parallel rather than sequentially. This is especially useful for complex graphics and networking tasks.
- The Java 1.0 and 1.1 Event Models:
Java 1.1's event handling model is substantially better than Java 1.0's. However, since many applets must still be written in Java 1.0 to accommodate Netscape 2 & 3 and Internet Explorer 3, you will master both event models during the class.
The course includes an illustrated workbook, Using Java 1.2, Java in a Nutshell, and handouts.
Course Outline
Prerequisites:
All students must have extensive HTML experience and be capable programmers, either from prior experience with a high-level language such as Perl, C, or C++ or from having taken CGI Scripting with Perl and JavaScript for Interactive Web Design courses and applied the skills learned to real-world projects. Those students who have not done object-based or object-oriented programming before are strongly urged to take JavaScript for Interactive Web Design prior to this course.
Development tool: Students will build their Java applets and applications using Symantec's Visual Cafe, which is widely regarded as the most powerful, easiest-to-use Java development tool available. For details on Visual Cafe, please visit
http://cafe.symantec.com/.
Student objectives for this four-day course:
- To master the basics of building Java applets and applications using Symantec Visual Cafe or Visual Cafe Pro
- To gain a comprehensive understanding of the Java Abstract Windowing Toolkit (AWT), its components, and its event handling framework, both under Java 1.0 and Java 1.1
- To learn how to build applets that can communicate with CGI scripts and databases
- To master debugging the syntax and programming logic of Java applets and applications
- To gain a basic understanding of the application of JavaBeans, the JDBC (Java Database Connectivity) classes, and other fundamental Java technologies
Day One (9:00 am to 5:00 pm):
9:00 Class Introduction
9:10
An Introduction to Java
The history of Java
Java's role versus those of CGI scripting and JavaScript
Java's unique status as the first full-featured, secure, portable, platform-independent programming language
An explanation of the Java "virtual machine" and a discussion of which browsers and platforms currently support Java
9:25 Exploration/Demonstration of Selected Java Applets
- Sample Java-based image maps and interactive forms
- The IQChart interactive stock tracking/graphing applet (an example of an applet connected to a back-end database)
- One to two additional, business-oriented "applets du jour"
9:40 Writing and Compiling a Java Applet
- An overview of the role of the compiler and how source code differs from compiled Java byte code
- How to compile a source code (.java) file into a compiled Java applet or application (.class) file using a command-line compiler
- Exercise:
Writing a small "Hello, World!" application, compiling it using the Sun JDK (Java Development Kit) compiler, and running it at the command line
10:05 Embedding a Java Applet in a Web Page
- Using the <APPLET> and <PARAM> tags to embed a Java applet in a Web page
- How to decide where to place the .class files for the applet
- Code and functional differences between Java applications and Java applets
- Exercise:
Changing the "Hello, World!" application from the previous exercise into an applet and embedding it in a Web page
- Exercise:
Embedding a sample applet in your Web page and modifying its behavior by using the <PARAM> tags
10:30 Break
10:40 An Introduction to Object-Oriented Programming
- A comparison of object-oriented and procedural programming
- The concept of an object as an abstract, developer-defined data type
- The Java object hierarchy and the role of abstraction, encapsulation, inheritance, and polymorphism.
- A brief review of dot notation, methods, and properties (which we assume students have learned from their own programming experience or the JavaScript for Interactive Web Design course)
- Passing variables by reference versus passing them by value
- Importing Java object packages into your applet
- An overview of the role of the AWT (application windowing toolkit)
- Note:
Although these concepts are challenging, Visual Cafe does an outstanding job of helping first-time object-oriented programmers understand and apply these concepts in their applets. The hands-on exercises during the rest of the course wil l repeatedly reinforce students' understanding of these concepts.
11:10 An Introduction to Symantec Visual Cafe
- A brief explanation of the differences between text-based and visual development environments
- A tour of the Visual Cafe workspace
- Creating a Java project and including your current HTML file within that project
- Opening existing Java code (in this case, your Hello, World! applet from earlier)
- Compiling and executing your Java code (and an explanation of Symantec's just-in-time compiler)
- Exercise:
Building an applet that generates a fireworks display with pause and resume button
11:50 Lunch
12:50 Using the Cafe Component Library: Multimedia
Visual Cafe features a variety of pre-written components that save programmers considerable coding. This section focuses on multimedia components; several subsequent sections focus on components for building interactive forms.
- Exercise and Lecture:
Building a slide show applet for your Web page using multimedia components from the Cafe component library. This applet will be embedded in the Web page of a mock real-estate firm and will enable visitors to view a series of residential properties.
- Creating a new project and opening a Form Designer window
- Adding the slide show component to the form and modifying its properties (specifying the graphics to use, etc.)
- Adding forward and back buttons beneath the slide show object and using Cafe's Interaction Wizard to give them the appropriate functionality
- Adding two SoundPlayer objects to the page and linking them to the forward and back buttons so that clicking the forward button generates one sound and clicking the back button generates another
- Compiling and saving the applet and adding it to the Web page
1:50 Dissecting the Source Code for the Slide Show Applet
During this section, we will view the source code for the applet and will dissect how it works. The goal of this section is to build a basic understanding of some of the features of the Java language, rather than teaching how to write Java source code from scratch.
- Importing the appropriate packages (Applet, AWT, etc.)
- Object hierarchy and class structure within the applet
- Life-cycle of the applet: init(), start(), paint(), stop(), and destroy()
- Methods, event handlers, and other aspects of the code
2:30 Break
2:40 Java Archiving Solutions
- Accelerating loading of classes via .zip archives
- Overview of the new JAR file format
2:55 Graphics, Text, and Fonts in Java
In this section, we will learn how to use the java.awt.Graphics, java.awt.Font, and java.awt.FontMetrics to control the size, shape, and positioning of graphics and text.
- Methods for creating and working with graphics primitives such as lines, rectangles, polygons, ovals, and arcs
- Methods for creating and working with characters and strings of text in different fonts
- Exercise:
Creating and positioning text via the Java AWT
3:50 Colors in Java
- Creating a color object in Java
- Using the color object to set background/foreground colors and to apply color to graphics and text
4:10 Handling mouseDown and mouseUp Events
- Capturing the position of the user's mouse when the mouse button is pressed or released
- Exercise:
Completing an applet that enables the user to create spots on a drawing surface simply by pointing and clicking at the location where a spot should be created
Day Two (9:00 am to 4:00 pm)
9:00 Handing mouseMove, mouseDrag, mouseEnter, and mouseExit Events
Capturing the position of the user's mouse as the mouse is moved or dragged
Capturing the location where the user's mouse enters or exits a specified region
Exercise: Completing a simple drawing applet that enables the user to draw lines on a graphics surface with the mouse
9:45 Keyboard Event Handling
- Detecting keyUp and keyDown events, both for standard keys and for special keys such as Home, End, and the function keys
- Exercise:
Completing an applet that enables the user to position a single character on a drawing surface and move it via the arrow keys
- Handling mouse events with modifier keys such as Ctrl and Alt
- More about the generic handleEvent() event handler and how an event is passed up the object hierarchy under the Java 1.0 event model
10:25 Break
10:35 An In-Depth Look at the Basic AWT Components
- Review of the AWT component hierarchy
- Methods for creating and working with labels, buttons, check boxes, radio buttons, choice menus, and text fields
- Exercise:
Using Visual Cafe Pro to build an applet from scratch that utilizes many of these AWT components, plus frames, menus, and dialog boxes
11:55 Lunch
12:55 Interaction Among Form Elements: A Java-Based Number Guesser
- Using Visual Cafe Pro to directly edit source code and to create event handler code
- Casting between numeric data types
- Using the Math.random() method
- Exercise:
Using Visual Cafe Pro to build a simple number guesser wherein the user must guess a number between one and ten. Students will first design the applet's appearance in the Form Designer and will then add the necessary underlying source code.
- Exercise:
Enhancing the applet to give high/low clues and extending the range of numbers to 100
2:30 Break
2:40 Using the Cafe Visual Debugger
- Step Into, Step Over, Step Out
- Exercise:
Using the step buttons to examine the inner workings of the applet from the previous exercise
- Setting standard and conditional breakpoints
- Exercise:
Setting breakpoints and using the Variables and Watch menus to observe the applet's activity and catch logic errors
- Other debugging views
3:00 Building a Java-Based Interest Calculator
- Exercise: Building a basic interest rate calculator applet
- Creating and working with Visual Cafe Pro's numericSpinner component
- Exercise:
Enhancing the applet to calculate interest across a user-selected number of years
4:00 Conclude for the Day
Day Three (9:00 am to 4:00 pm)
9:00 Using AWT Layout Managers
- Setting the layout of components in the applet with setLayout()
- The FlowLayout class
- The GridLayout class
- The BorderLayout class
- The CardLayout class
- The GridBagLayout class
- Insets
- Exercise:
Using a layout manager to position components within an applet
9:50 Additional Information about AWT Components
- Nesting components within other components (e.g., multiple panels within another panel)
- Text areas
- Scrolling lists
- Windows, frames, and dialogs
- Exercise:
Examining a complex AWT components example
10:35 Break
10:45 Applet-Browser Interaction
- Using showStatus()to print messages to the status bar
- Using getAppletInfo() to embed copyright and credits information
- Creating URL objects
- Using showDocument() to force the browser to load another URL
- Exercise:
Completing a bookmark buttons applet
11:45 Lunch
12:45 Java Applet-CGI Interaction
- Comparison of HTML and Java forms
- Using WestLake's CGI.class file (free with the class) to pass data from a Java-based form to a CGI script
- Exercise:
Working with an example
- Exercise:
Building a Java-based interface to a database-connected CGI script
2:00 Break
2:10 The Java 1.1x Event Model
- Overview of what's new in the Java 1.1x event model
- Implementing listeners, either within the current class or as a separate class
- Inner classes
- Handling mouse and keyboard events, as well as other events, under the 1.1x model
- Compatibility issues
- Exercise:
Porting two applets from earlier in the class to the 1.1x event model
3:10 Threads
- When would you use multiple threads?
- Creating threads in Java and executing code within them
- Exercise:
Building a multithreaded animation in Visual Cafe Pro
- Dissecting the source of the animation applet from this exercise
4:00 Conclude for the Day
Day Four (9:00 am to 4:00 pm)
9:00 Introduction to JDBC
- Two-tier vs. three-tier architecture
- Overview of the java.sql package
- Setup issues and loading the appropriate driver
- Establishing a database connection
- Preparing an SQL SELECT statement and executing it
- Iterating through the result set and displaying these results for the user
- Using Symantec's multilist component for displaying results
- Exercise:
Building a "database browser" that enables the user to type in an SQL select statement and see the results displayed in a TextArea.
- Exercise:
Upgrading the applet from the previous exercise to display the results in a multilist rather than a TextArea
10:30 Break
10:40 Working with MetaData
- Overview of the MetaData that can be returned about a result set
- Techniques for working with MetaData
- Exercise:
Enhancing the applet from the previous exercise to be more user-friendly. Rather than type in an SQL statement, the user will pick a column to search from a pull-down list (which will automatically be populated with the column names, as gleaned from the MetaData), then type in the text to search for.
11:15 Adding Records to the Database
- Compare/contrast of the executeQuery() method (used for SELECTs) and the executeUpdate() method (used for INSERT, UPDATE, and DELETE), including the differences in the result sets returned by the two methods.
- Overview of Transactions (commiting and rolling back) and Locking
- Exercise:
Building an applet that enables the user to add records to the database.
12:10 Lunch
1:10 Updating and Deleting Records from the Database
- Design issues and recommendations for building applets that enable the user to edit the data in the database.
- Exercise: Building an applet that enables the user to look up and edit the records in a database. These records will be displayed in a multilist component. As part of the exercise, the user will have to implements basic transactions and locking.
- Exercise: Upgraded the applet from the previous exercise so that the user can also delete records from the database.
2:35 Break
2:45 Introduction to JavaBeans
- The value of Beans: introspection, configuration, and serialization
- Designing a Bean in Visual Cafe 2.5, including an overview of how to determine which methods, properties, and events to expose
- JARing and distributing your bean
- Exercise:
Building a database connectivity Bean that shortens the process of building a database-aware applet by several steps.
3:45 Conclusion
- Overview of Swing and the new features of Java 1.2
- Suggestions for further learning
- Conclusion and evaluations