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

Introduction to J2EE and WSAD by bzs12927

VIEWS: 8 PAGES: 30

									Introduction to J2EE and
         WSAD



Reference: Java Programming: Advanced Topics
                                               1
                Objectives

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




                                                 2
    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




                                                     3
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
  environments
                                                   4
     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)




                                                 5
Containers in the n-Tier J2EE
        Architecture




                                6
         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

                                           7
  Object-Oriented Programming
             in Java

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




                                                           8
  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




                                                                 9
   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




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




                                               11
    Building a Program with
     Application Developer
• IDE provides productivity tools for building,
  debugging, testing, and packaging Java
  programs
• 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

                                                  12
         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

                                         13
     Resources and Workspaces
• Workspace
  – Collection of resources (i.e., projects, folders and
    files).
  – 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

                                                           14
Application Developer Window




                               15
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
      appear.



                                                         16
The Java Perspective of Application
            Developer




                                  17
Application Developer Tutorial
            (Cont.)
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
        button
   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.



                                                                  18
Loading the Version 1.4 JRE into
     WSAD (optional step)




                               19
Selecting a Default JRE for WSAD
          (optional step)




                                   20
Application Developer Tutorial
            (Cont.)
Step 3: Creating a Java project, package, and
  class:
  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.



                                                            21
The Create Java Project Wizard




                                 22
The Create a Java Package Wizard
              (Cont.)




                                   23
The Create a Java Class Wizard




                                 24
Application Developer Tutorial
            (Cont.)
• Step 4a: Entering the code for the HelloWorld class
  – Import: import java.io.*;
      • 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
                InputStreamReader(System.in));
            String name = br.readLine();
            hw.setName(name);
            hw.sayHello();
       }
   – Code-assist feature: Ctrl + Space


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

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

                                                              26
Application Developer Tutorial
            (Cont.)
Step 5: Running the program
  – Select HelloWorld.java 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.




                                                      27
  A Code-Assist Feature of the
Application Developer Java Editor




                                28
Running a Java Application in
   Application Developer




                                29
 Application Developer Tutorial
             (Cont.)
Step 6: Exporting code and closing Application
   Developer
  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