Professional Documents
Culture Documents
J2EE (Workshop) : Dhiraj Thakkar (SEG-Director) (MS-IT, SE-J2EE Application 2.5 Years)
J2EE (Workshop) : Dhiraj Thakkar (SEG-Director) (MS-IT, SE-J2EE Application 2.5 Years)
J2EE (Workshop) : Dhiraj Thakkar (SEG-Director) (MS-IT, SE-J2EE Application 2.5 Years)
Core Java
Web Application
XML
Core Java
Web Application
XML
Core Java
Web Application
XML
Principles of XML
Creating XML
Validating XML
Viewing XML
XML Vocabularies
DTD (Document Type
Definition)
Core Java
Web Application
XML
JSF framework
To master configuring JSF
How JSF integrates with JSP
How to use JSF UI components
Navigation and event handling
JSF form validation framework
Custom JSF components
Core Java
Web Application
XML
Dream Weaver MX
NetBeans
Method Method
Data
Method
Method
Object
Person
Name Data
BasicPay
Salary()
Methods
Tax()
Representation of an object
Property Inheritance
Dhiraj Thakkar (MS-IT ,SE- J2EE Applications)
Polymorphism
Polymorphism is another important OOP concept.
Polymorphism means ability to take more than one form.
Shape
Draw()
Polymorphism
Hardware and
Programmer
Operating System
Programmer
JAVA COMPILER
(translator)
JAVA INTERPRETER
(one for each different system)
Core Classes
language
Utilities
Input/Output
Low-Level Networking
Abstract Graphical User Interface
Internet Classes
TCP/IP Networking
WWW and HTML
Distributed Programs
C++
C Java
Subset of C++
Dhiraj Thakkar (MS-IT ,SE- J2EE Applications)
Java better
Typedefs, Defines, orthan C++
Preprocessor ?
No Global Variables
No Goto statements
?
No Pointers
No Unsafe Structures
No Multiple Inheritance
No Operator Overloading
Stand-alone applications
Web applications (applets)
1 2 3 4 5
APPLET hello.class Create Accessing The browser
Development AT SUN’S Applet from creates
“hello.java” WEB tag in Unimelb.edu.au a new
AT SERVER HTML window and
SUN.COM document a new thread
and
then runs the
code
Hello Java
<app=
“Hello”> The Internet
Hello
Interactive WWW
Flashy animation instead of static web
pages
Applets react to users input and
dynamically change
Display of dynamic data
WWW with Java - more than a document
publishing medium
Java Source
javadoc HTML Files
Code
javac
java jdb
Outout
Dhiraj Thakkar (MS-IT ,SE- J2EE Applications)
Let us Try Out
Compilation
# javac hello.java
results in HelloInternet.class
Execution
# java HelloInternet
Hello Internet
#
char
Two-byte unicode
Assignment with ‘ ‘
e.g. char c = ‘h’;
boolean
true or false
e.g. boolean x = true;
if (x){…};
Format:
arrayname[position number]
size
int x = myString.length ();
equality / comparison
if (er.equals (”Stamp
Required”))
substring
p = s.substring (0,s.indexOf
(’-’));
concatenation
System.out.print (”Hello, “ +
name);
String s = null;
String t = “”;
String u = “The letter u.”;
String v = u;
Strings are immutable
StringBuffer is a modifiable
alternative
protected X X X
public X X X X
package X X
Dhiraj Thakkar (MS-IT ,SE- J2EE Applications)
Initializing Objects
Initialization is a must every time an object is
created out of a class.
Java compiler will initialize all class members and
creating default constructors that initialize data
members as follows: 0 for primitive numeric
types, false for boolean, null for references.
Initialization mainly happened in the class
constructors.
A class could have more than one way
(constructor) of initialization.
Initializers are passed as arguments to constructor
Dhiraj Thakkar (MS-IT ,SE- J2EE Applications)
Object Instantiating
Classes only describe data types. To put
then in use at runtime, objects have to be
created (instantiated) from them.
“new” keyword is used to instantiate an
object from a class. Example:
public Font myFnt = new
Font(“Arial”, Font.ITALIC, 12);
No objects can be instantiated from
Abstract classes. You can not use new here.
Base Class
Java.awt.Dialog (or Parent Class
or Superclass)
Is-a relationship
Derived Class
Java.awt.FileDialog (or Child Class
or Subclass)
Is-a relationship
Method print_mailing_list
is polymorphic
types)
The binding of messages to method definitions is
instance-dependent, and it is known as dynamic
binding
It has to be resolved at run-time
Dynamic binding requires the virtual keyword in C++
(e.g. Eiffel)
Other languages, like C++, require a
inheritance
A class may inherit multiple interfaces, but, in the absence
of implementations, the collision is irrelevant
Throwable classes
Catching exceptions
Throwing exceptions
Checked exceptions
Error handling
Finally
ClassCastException Object x =
new Integer(1);
String s = (String) x;
...
RuntimeException ...
Classes derived from Classes derived from
RuntimeException are ... Exception are used
used for ordinary system- for ordinary errors that a
generated errors, like program might want to
ArithmeticException catch and recover from
Dhiraj Thakkar (MS-IT ,SE- J2EE Applications)
Outline
Throwable classes
Catching exceptions
Throwing exceptions
Checked exceptions
Error handling
Finally
stops…
…then y gets a chance ...
Throwable classes
Catching exceptions
Throwing exceptions
Checked exceptions
Error handling
Finally
System.out.print("1, ");
try {
throw new OutOfGas();
}
catch (OutOfGas e) {
System.out.print("2, ");
}
System.out.println("3");
try {
throw new OutOfGas("You have run out of gas.");
}
catch (OutOfGas e) {
System.out.println(e.getMessage());
}
Throwable classes
Catching exceptions
Throwing exceptions
Checked exceptions
Error handling
Finally
...
RuntimeException ...
...
or declare it throws it
too… ...
f’s activation
record
Throwable classes
Catching exceptions
Throwing exceptions
Checked exceptions
Error handling
Finally
if (s.hasMore()) x = s.pop();
else …
/**
* Reset the error flag. We set it to false.
*/
public void resetError() {
error = false;
}
Throwable classes
Catching exceptions
Throwing exceptions
Checked exceptions
Error handling
Finally
Farewell to Java
Client Interactive
Applet
web, security, and Server
client
consistency
Slow to download, inconsistent VMs
(besides, flash won this war)
//HelloWorld.java
import java.applet.Applet;
import java.awt.*;
}
}
<HTML>
<TITLE>HELLO WORLD APPLET</TITLE>
<HEAD>THE HELLO WORLD APPLET</HEAD>
<APPLET CODE=“HelloWorld.class” width=500
height=500>
</APPLET>
</HTML>
Using AppletViewer
Using Browser