08-10-2016, 09:50 AM
[attachment=72699]
What is Java?
Java was conceived by James Gosling at Sun
Microsystems Inc. in 1991
Java is platform independent language
Java programming is a/an object-oriented
programming.
Object oriented language
The world around us consists of objects.
Let the program consist of objects.
The program consist of objects.
Objects of the same kind form a class.
Building JAVA Application
Prepare the file HelloWorld.java using an
editor
Invoke the compiler:
javac HelloWorld.java
This creates HelloWorld.class
Run the java interpreter:
java HelloWorld
What is an applet?
An applet is a small Java program that is
embedded and ran in some other Java
interpreter program such as
a Java technology-enabled browser
Sun’s applet viewer program called
appletviewer
Life Cycle of an Applet:
init: This method is intended for whatever initialization
is needed for an applet.
start: This method is automatically called after init
method. It is also called whenever user returns to the
page containing the applet after visiting other pages.
stop: This method is automatically called whenever the
user moves away from the page containing applets.
This method can be used to stop an animation.
destroy: This method is only called when the browser
shuts down normally.
Applet Execution - 3
The applet is running and rendered on the
web page.
Every Applet needs to implement one or
more of the init(), the start( ) and the
paint( ) methods.
At the end of the execution, the stop( )
method is invoked, followed by the
destroy( ) method to deallocate the
applet’s resources.
Applet life cycle
browser visits page containing an applet
browser calls init on that applet, once
browser calls start on that applet
browser goes away from that page
browser calls stop on that applet
browser comes back to that page
browser calls start again on that applet
browser shuts down
browser calls destroy on the applet, once
Summary
An applet is a Java class
Its code is downloaded from a web server
It is invoked by a browser when it scans a web page and
encounters a class specified with the APPLET tag
For security reason, the execution of an applet is
normally subject to restrictions:
applets cannot access files in the file system on the client host
Applets cannot make network connection exception to the
server host from which it originated
What is Java?
Java was conceived by James Gosling at Sun
Microsystems Inc. in 1991
Java is platform independent language
Java programming is a/an object-oriented
programming.
Object oriented language
The world around us consists of objects.
Let the program consist of objects.
The program consist of objects.
Objects of the same kind form a class.
Building JAVA Application
Prepare the file HelloWorld.java using an
editor
Invoke the compiler:
javac HelloWorld.java
This creates HelloWorld.class
Run the java interpreter:
java HelloWorld
What is an applet?
An applet is a small Java program that is
embedded and ran in some other Java
interpreter program such as
a Java technology-enabled browser
Sun’s applet viewer program called
appletviewer
Life Cycle of an Applet:
init: This method is intended for whatever initialization
is needed for an applet.
start: This method is automatically called after init
method. It is also called whenever user returns to the
page containing the applet after visiting other pages.
stop: This method is automatically called whenever the
user moves away from the page containing applets.
This method can be used to stop an animation.
destroy: This method is only called when the browser
shuts down normally.
Applet Execution - 3
The applet is running and rendered on the
web page.
Every Applet needs to implement one or
more of the init(), the start( ) and the
paint( ) methods.
At the end of the execution, the stop( )
method is invoked, followed by the
destroy( ) method to deallocate the
applet’s resources.
Applet life cycle
browser visits page containing an applet
browser calls init on that applet, once
browser calls start on that applet
browser goes away from that page
browser calls stop on that applet
browser comes back to that page
browser calls start again on that applet
browser shuts down
browser calls destroy on the applet, once
Summary
An applet is a Java class
Its code is downloaded from a web server
It is invoked by a browser when it scans a web page and
encounters a class specified with the APPLET tag
For security reason, the execution of an applet is
normally subject to restrictions:
applets cannot access files in the file system on the client host
Applets cannot make network connection exception to the
server host from which it originated