Course Code P 08 MCA 421 Course Title

  • Slides: 36
Download presentation
Course Code : P 08 MCA 421 Course Title : Topics in Enterprise Architecture-I

Course Code : P 08 MCA 421 Course Title : Topics in Enterprise Architecture-I Text Books : 1. Herbert Schildt : Java The Complete Reference, 7 th Edition, Tata Mc. Graw Hill, 2007 2. Jim Keogh : J 2 EE The Complete Reference, Tata Mc. Graw Hill 2007

Introduction Organization of the Book

Introduction Organization of the Book

Introduction to Java § § § Java and Java applications Java Development Kit(JDK) Java

Introduction to Java § § § Java and Java applications Java Development Kit(JDK) Java is interpreted, Byte code, JVM Object-Oriented Programming Simple Java programs Data types and other tokens: Boolean variables, int , long, char operators, arrays, whitespaces, literals, assigning values 3

Continues…. §Creating and Destroying Objects §Access Specifies, Operators and Expressions : Arithmetic Operators, Bitwise

Continues…. §Creating and Destroying Objects §Access Specifies, Operators and Expressions : Arithmetic Operators, Bitwise operators, Relational operators, The assignment operator, The ? Operator, Operator precedence §Logical expression §Type casting §Strings §Control Statements §Selection Statements §Iteration Statements §Jump Statements 4

Classes, Inheritance, Exception, Applets §Classes in Java §Super classes §Constructors §Creating Instances of class

Classes, Inheritance, Exception, Applets §Classes in Java §Super classes §Constructors §Creating Instances of class §Inner classes §Inheritance: Simple, Multiple and Multilevel Inheritance §Overriding, Overloading §Exception Handling : Exception handling in java, §The Applet Class : Two types of Applets, Applet basics, Applet Architecture, An Appletskeleton, Simple Applet display methods, Requesting repainting, Using the Status Window, The HTML APPLET tag, Passing parameters to Applets, get. Documentbase() and get. Codebase(), Applet. Context and show. Document(), The Audio. Clip Interface, The Applet. Stub Interface, Output to the Console 5

Multi Threaded Programming , Event Handling §Multi Threaded Programming §What are threads? §How to

Multi Threaded Programming , Event Handling §Multi Threaded Programming §What are threads? §How to make the classes threadable §Extending threads §Implementing runnable §Synchronization §Changing state of the thread §Bounded buffer problems §Read-Write problem §Producer-Consumer problems §Event Handling : Two Event handling Mechanisms §The delegation event model §Event classes §Sources of Events §Event listener interfaces §Using the delegation event model §Adapter classes Inner classes 6

Swings §Swings: The origins of Swing, Two key Swing features, Components and Containers, The

Swings §Swings: The origins of Swing, Two key Swing features, Components and Containers, The Swing Packages, A simple Swing Application, Create a Swing Applet §Jlabel and Image. Icone §JText. Field §The Swing Buttons §Jtabbedpane §JScroll. Pane §Jlist §JCombo. Box §JTable 7

Java 2 Enterprise Edition Overview, Database Access §Overview of J 2 EE and J

Java 2 Enterprise Edition Overview, Database Access §Overview of J 2 EE and J 2 SE §The concept of JDBC §JDBC Driver Types §JDBC Packages §A Brief Overview of the JDBC process §Database Connection §Associating the JDBC /ODBC Bridge with the Database §Statement Objects §Result. Set §Transaction Processing §Metadata §Data Types §Exceptions 8

Servlets §Background §The life Cycle of a Servlet §Using Tomcat for Servlet Development §A

Servlets §Background §The life Cycle of a Servlet §Using Tomcat for Servlet Development §A simple Servlet §The Servlet API §The javax. servlet Package §Reading Servlet Parameter §The javax. servlet. http Package §Handling HTTP Requests and Respones §Using Cookies §Session Tracking 9

JSP, RMI §Java Server Pages(JSP) §JSP, JSP Tags §Tomcat §Request String §User Sessions §Cookies

JSP, RMI §Java Server Pages(JSP) §JSP, JSP Tags §Tomcat §Request String §User Sessions §Cookies §Session Objects §Java Remote Method Invocation §Remote Method Invocation Concept : Server side and Client side 10

Enterprise Java Beans §Deployment Descriptors §Session Java Bean §Request String §Entity Java Bean §Message-Driven

Enterprise Java Beans §Deployment Descriptors §Session Java Bean §Request String §Entity Java Bean §Message-Driven Bean §The JAR file 11

What Is Java? F History F Characteristics of Java 12

What Is Java? F History F Characteristics of Java 12

History F James Gosling and Sun Microsystems F Oak F Java, May 20, 1995,

History F James Gosling and Sun Microsystems F Oak F Java, May 20, 1995, Sun World F Hot. Java – The first Java-enabled Web browser F JDK Evolutions F J 2 SE, J 2 ME, and J 2 EE (not mentioned in the book, but could discuss here optionally) 13

Characteristics of Java F Java is simple F Java is object-oriented F Java is

Characteristics of Java F Java is simple F Java is object-oriented F Java is distributed F Java is interpreted F Java is robust F Java is secure F Java is architecture-neutral F Java is portable F Java’s performance F Java is multithreaded F Java is dynamic 14

JDK Versions F JDK 1. 02 (1995) F JDK 1. 1 (1996) F Java

JDK Versions F JDK 1. 02 (1995) F JDK 1. 1 (1996) F Java 2 SDK v 1. 2 (a. k. a JDK 1. 2, 1998) F Java 2 SDK v 1. 3 (a. k. a JDK 1. 3, 2000) F Java 2 SDK v 1. 4 (a. k. a JDK 1. 4, 2002) 15

JDK Editions F Java Standard Edition (J 2 SE) – J 2 SE can

JDK Editions F Java Standard Edition (J 2 SE) – J 2 SE can be used to develop client-side standalone applications or applets. F Java Enterprise Edition (J 2 EE) – J 2 EE can be used to develop server-side applications such as Java servlets and Java Server. Pages. F Java Micro Edition (J 2 ME). – J 2 ME can be used to develop applications for mobile devices such as cell phones. This book uses J 2 SE to introduce Java programming. 16

Java IDE Tools F Forte by Sun Micro. Systems F Borland JBuilder F Microsoft

Java IDE Tools F Forte by Sun Micro. Systems F Borland JBuilder F Microsoft Visual J++ F Web. Gain Café F IBM Visual Age for Java 17

Getting Started with Java Programming FA Simple Java Application F Compiling Programs F Executing

Getting Started with Java Programming FA Simple Java Application F Compiling Programs F Executing Applications 18

A Simple Application Example 1. 1 //This application program prints Welcome //to Java! package

A Simple Application Example 1. 1 //This application program prints Welcome //to Java! package chapter 1; public class Welcome { public static void main(String[] args) { System. out. println("Welcome to Java!"); } } Source Run NOTE: To run the program, install slide files on hard disk. 19

Creating and Compiling Programs F On command line – javac file. java 20

Creating and Compiling Programs F On command line – javac file. java 20

Executing Applications F On command line – java classname 21

Executing Applications F On command line – java classname 21

Example javac Welcome. java Welcome output: . . . 22

Example javac Welcome. java Welcome output: . . . 22

Compiling and Running a Program Where are the files stored in the directory? 23

Compiling and Running a Program Where are the files stored in the directory? 23

Anatomy of a Java Program F Comments F Package F Reserved words F Modifiers

Anatomy of a Java Program F Comments F Package F Reserved words F Modifiers F Statements F Blocks F Classes F Methods F The main method 24

Comments In Java, comments are preceded by two slashes (//) in a line, or

Comments In Java, comments are preceded by two slashes (//) in a line, or enclosed between /* and */ in one or multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*, it scans for the next */ and ignores any text between /* and */. 25

Package The second line in the program (package chapter 1; ) specifies a package

Package The second line in the program (package chapter 1; ) specifies a package name, chapter 1, for the class Welcome. Forte compiles the source code in Welcome. java, generates Welcome. class, and stores Welcome. class in the chapter 1 folder. 26

Reserved Words Reserved words or keywords are words that have a specific meaning to

Reserved Words Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program. For example, when the compiler sees the word class, it understands that the word after class is the name for the class. Other reserved words in Example 1. 1 are public, static, and void. Their use will be introduced later in the book. 27

Modifiers Java uses certain reserved words called modifiers that specify the properties of the

Modifiers Java uses certain reserved words called modifiers that specify the properties of the data, methods, and classes and how they can be used. Examples of modifiers are public and static. Other modifiers are private, final, abstract, and protected. A public datum, method, or class can be accessed by other programs. A private datum or method cannot be accessed by other programs. Modifiers are discussed in Chapter 6, "Objects and Classes. " 28

Statements A statement represents an action or a sequence of actions. The statement System.

Statements A statement represents an action or a sequence of actions. The statement System. out. println("Welcome to Java!") in the program in Example 1. 1 is a statement to display the greeting "Welcome to Java!" Every statement in Java ends with a semicolon (; ). 29

Blocks A pair of braces in a program forms a block that groups components

Blocks A pair of braces in a program forms a block that groups components of a program. 30

Classes The class is the essential Java construct. A class is a template or

Classes The class is the essential Java construct. A class is a template or blueprint for objects. To program in Java, you must understand classes and be able to write and use them. The mystery of the class will continue to be unveiled throughout this book. For now, though, understand that a program is defined by using one or more classes. 31

Methods What is System. out. println? It is a method: a collection of statements

Methods What is System. out. println? It is a method: a collection of statements that performs a sequence of operations to display a message on the console. It can be used even without fully understanding the details of how it works. It is used by invoking a statement with a string argument. The string argument is enclosed within parentheses. In this case, the argument is "Welcome to Java!" You can call the same println method with a different argument to 32

main Method The main method provides the control of program flow. The Java interpreter

main Method The main method provides the control of program flow. The Java interpreter executes the application by invoking the main method. The main method looks like this: public static void main(String[] args) { // Statements; } 33

Displaying Text in a Message Dialog Box you can use the show. Message. Dialog

Displaying Text in a Message Dialog Box you can use the show. Message. Dialog method in the JOption. Pane class. JOption. Pane is one of the many predefined classes in the Java system, which can be reused rather than “reinventing the wheel. ” Source Run 34

The show. Message. Dialog Method JOption. Pane. show. Message. Dialog(null, "Welcome to Java!", "Example

The show. Message. Dialog Method JOption. Pane. show. Message. Dialog(null, "Welcome to Java!", "Example 1. 2", JOption. Pane. INFORMATION_MESSAGE)); 35

The exit Method Use Exit to terminate the program and stop all threads. NOTE:

The exit Method Use Exit to terminate the program and stop all threads. NOTE: When your program starts, a thread is spawned to run the program. When the show. Message. Dialog is invoked, a separate thread is spawned to run this method. The thread is not terminated even you close the dialog box. To terminate thread, you have to invoke the exit method. 36