Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 
Training Index

Introduction to the JavaBeans API, Magercise 2 Help
Working with Beans

by John Zukowski, MageLang Institute

[Magercise 2 | API Docs | Short Course | Magercises]

Help is available for each task.

Task 1

The first step is to create a working directory somewhere on your filesystem, hereafter referred to as workingdir.


To avoid confusion, create a new directory instead of using an existing directory that has existing/other files.

Task 2

Next, create the directory simple (all lowercase characters) directly under workingdir.


To avoid subsequent confusion, create and verify that the directory name contains all lowercase characters. The directory simple (lowercase "s") will house the Simple class (uppercase "S"), which belongs to the simple package (lowercase "s"). The package and directory names must match exactly, and in some Bean-aware environments, they must be lowercase, or you will get mysterious behavior that will tax your very sanity.

Task 3

Next, (1) save all the solution files, except Simple.java, within workingdir and (2) save the solution file Simple.java within simple, that is, within workingdir/simple.


In the next task, the Bean Simple (uppercase "S") will be compiled in the simple package (lowercase "s"), that is, simple.Simple. Thus, the directory simple will house the Simple class. The package and directory names must match exactly, and in some Bean-aware environments, they must be lowercase, or you will get mysterious behavior that will tax your very sanity.

Task 4

Compile Simple.java from workingdir by including the simple directory in the path specification.


From a command window type (excluding the prompt):

C:\workingdir>javac simple\Simple.java   [DOS] or
/workingdir>javac simple/Simple.java     [UNIX]

An alternative approach, if you prefer graphical tools, is to build the simple package within your JavaTM development environment.

Verify that Simple.class exists within the simple directory by typing (excluding the prompt):

C:\workingdir>dir simple

Task 5

Build Simple.jar from workingdir by executing the file MakeSimpleJar.bat (Windows) or MakeSimpleJar.sh (UNIX).


From a command window type (excluding the prompt):

C:\workingdir>MakeSimpleJar

Verify the contents of Simple.jar by executing the file ListSimpleJar.bat (Windows) or ListSimpleJar.sh (UNIX):

C:\workingdir>ListSimpleJar
   180 Tue Oct 13 16:45:38 MDT 1998 META-INF/MANIFEST.MF
   514 Tue Oct 13 16:43:30 MDT 1998 simple/Simple.class

The contents of simple.txt, a text file, is used to build the manifest file, MANIFEST.MF, within the JAR file--the descriptor file simple.txt is not the manifest file.

Task 6

Next, load the Simple Bean into the BeanBox using "LoadJar..." from the BeanBox "File" menu.


Start up the BeanBox, select "LoadJar..." from the BeanBox "File" menu, and then navigate to your workingdir and open/load Simple.jar.

Task 7

Lastly, select Simple from the palette and create an instance on the worksheet.


When you load Simple.jar, it will be the last entry in the palette; you may have to scroll down in the palette to locate "Simple".

Return to Magercise 2

Copyright © 1998-1999 MageLang Institute. All Rights Reserved.


[ This page was updated: 27-Oct-99 ]

Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-99 Sun Microsystems, Inc.
All Rights Reserved. Legal Terms. Privacy Policy.