Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

Introduction to J2EE and WSAD by bzs12927


									Introduction to J2EE and

Reference: Java Programming: Advanced Topics

• Introduction to Java 2 Enterprise Edition (J2EE)
• Enter, compile, and run a sample program using
  IBM WebSphere Studio Application Developer
  5.1 (WSAD)

    Overview of the Java Platform

•   The Java language is object-oriented
•   Java code is architecture-neutral and portable
•   Java is network-savvy
•   Java programs are secure
• Java is high performance

Java Programs and Components
• JavaBeans: classes or program components
  that conform to strict programming conventions
• Applets: components that can be launched from
  HTML documents and run in a Web browser or
  applet viewer utility
• Servlets: components that generate content for
  Web pages at runtime
• Enterprise JavaBeans (EJBs): server-side
  components used in distributed enterprise
     The Three Editions of the
         Java 2 Platform

• The Java 2 platform comes in three versions:
  – Java 2 Standard Edition (J2SE)
  – Java 2 Enterprise Edition (J2EE)
  – Java 2 Micro Edition (J2ME)

Containers in the n-Tier J2EE

         A Brief History of the
            Java Platform
•   1995: Version 1.0 (Sun Microsystems)
•   1997: Version 1.1
•   1998: Java 2 platform
•   1999: J2SE, J2EE, and J2ME
•   2001: Version 1.3 of J2SE
•   2002: Version 1.4
•   2002: Version 1.3 of J2EE

  Object-Oriented Programming
             in Java

• The key benefits of object-oriented
  programming are:
  – code reuse
  – flexibility to respond to changing circumstances and
  – ease of maintenance

  Object-Oriented Programming
         in Java (Cont.)
• A program is a collection of objects that send
  messages to each other
• Object-oriented analysis and design (OOAD):
  – First stage: perform object-oriented problem analysis
  – Second stage:
     • Identify classes to be implemented
     • Identify fields and methods the classes must contain to
       model the behavior of real-life objects

   Object-Oriented Methodology

• Java lends itself to iterative and incremental
  object-oriented development methodology
• In large projects, functionality is typically added in
  stages and each identifiable stage is an increment
• An iteration is a short-term development cycle
  within an increment

Object-Oriented Features of Java
• Java supports the following fundamental
  features of all object-oriented languages:
  –   Abstract data types
  –   Encapsulation
  –   Inheritance
  –   Polymorphism

    Building a Program with
     Application Developer
• IDE provides productivity tools for building,
  debugging, testing, and packaging Java
• IBM WebSphere Studio Application
  Developer (WSAD) includes debug, test,
  and deployment tools
• The Application Developer IDE is organized
  into windows called perspectives
• Each perspective groups work and
  information areas called views

         Starting WSAD 5.1
• Start | All Programs | IBM Websphere
  Studio | Application Developer 5.1
• To start WSAD with the workspace
  location prompted:
  – Open a command prompt
  – cd “C:\Program Files\IBM\WebSphere
    Studio\Application Developer\v5.1”
  – wsappdev -setworkspace

     Resources and Workspaces
• Workspace
  – Collection of resources (i.e., projects, folders and
  – Exactly one workspace is active at a time.
• Project
  – Contain folders and files, but not projects.
  – Cannot be named “.metadata”
• Folder
  – Contain other folders and/or files
• Reference:
  – WSAD Help Contents | Workspaces

Application Developer Window

Application Developer Tutorial
Reference: Pages 45 to 56, Java Programming:
  Advanced Topics

Step 1: Opening the Java perspective:
   1. Click the Open a Perspective button, in the
      perspectives toolbar.
   2. A drop-down menu appears. Select Java or the
      name of the perspective you want, and click OK
      to open the perspective.
   3. After a brief pause, the Java perspective should

The Java Perspective of Application

Application Developer Tutorial
Note: Changing to JDK1.4 is an optional step.

Step 2: Selecting version 1.4 of the JRE:
   1. To set the JRE in Application Developer, in the main menu
        select Window and then Preferences.
   2. In the list on the left of the Preferences window, expand
        Java and then select Installed JREs. Click the Add
   3. Fill in the Add JRE dialog box, and click OK.
   4. When you return to the Preferences dialog box, check the
        box beside the JRE, and click OK.

Loading the Version 1.4 JRE into
     WSAD (optional step)

Selecting a Default JRE for WSAD
          (optional step)

Application Developer Tutorial
Step 3: Creating a Java project, package, and
  1. Click the Create a Java Project toolbar button, fill
     in the Java Project dialog box, and click Finish.
  2. Click the Create a Java Package toolbar button,
     to add a Java package to the selected project. Fill
     in the dialog box, and click Finish.
  3. Click the Create a Java Class toolbar button to
     add a Java class to the selected package. Fill in
     the dialog box, and then click Finish.

The Create Java Project Wizard

The Create a Java Package Wizard

The Create a Java Class Wizard

Application Developer Tutorial
• Step 4a: Entering the code for the HelloWorld class
  – Import: import*;
      • Alternative: Right-click, Source | Organize Imports
   – Class field: String name = null;
   – main() method:
       public static void main(String[] args) throws IOException {
            HelloWorld hw = new HelloWorld();
            System.out.print("What is your name? ");
            BufferedReader br = new BufferedReader(new
            String name = br.readLine();
   – Code-assist feature: Ctrl + Space

Application Developer Tutorial
• Step 4b: Entering the code for the HelloWorld
  – sayHello() method:
     void sayHello() {
           System.out.println("Hello " + getName());

  – Add Getter/Setter methods:
     • Right-click field name, Source | Generate Getter and
  – Format: Right-click, Source | Format
  – Save & compile: Ctrl-S

Application Developer Tutorial
Step 5: Running the program
  – Select in the Package Explorer
    view. Click the down arrow beside the Run,
    toolbar button.
  – From the pop-up menu select Run As and then
    Java Application, enter command-line arguments
    or pass javac arguments to the compiler, select
    Run and complete the dialog boxes.

  A Code-Assist Feature of the
Application Developer Java Editor

Running a Java Application in
   Application Developer

 Application Developer Tutorial
Step 6: Exporting code and closing Application
  1. To use the Export Wizard, highlight the item you
      want to export and select Export from the File
      menu. Complete dialog boxes to specify exactly
      what to export, select how to package the
      exported code, and identify the destination.
      - e.g., export to WSADdemo.jar
  2. When you are satisfied, you can close Application
      Developer by selecting Exit from the File menu
      or clicking the Windows close box.

  Next Step: Read Help Contents | Getting Started |
     Workbench basics                                    30

To top