Upload
myrajendra
View
1.229
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
1
Basics of Applet
2
Objective
On completion of this period, you will be able to learn
• Basics of applet
3
Recap
In the previous classes, we have studied about
• The various I/O streams and classes
• How to write console based Java programs or
applications
4
Basics of Applets
• Applets are small Java programs that are used in Internet computing
• Applets • Transported over the Internet• Automatically installed in client machine• Run as part of a web document• Applets can be run using a tool ‘appletviewer’
5
Basics of Applets contd..
• Applets interact with the user through the AWT, not through the console-based I/O classes
• Clients download applets via Web browser• Browser runs applet in a Java Virtual Machine
(JVM)
6
Basics of Applets contd..
• Applets can be classified into two types
• Local applets
• Remote applets
• Local applet
• Developed and stored in local system
• No need for internet connection for the local system
• Local directories were searched to locate the specified applet
7
Basics of Applets contd..
• Remote applet
• Developed by someone else
• Stored on a remote computer connected to the internet
• Our system needs an internet connection
• The applet is downloaded into our local system via internet
• Run it on our system
8
Loading of Remote Applet
Internet
Local Computer (Client)
Remote Computer (Server)
Remote Applet
Fig. 53.1 Loading of remote applet
Applet
9
Web Browsers Requests Applet
Fig. 53.2 Request for applet
1. Browser shows web document
2. Web document contains an applet tag
3. Web browser identifies the tag
4. Client computer makes a request to web browser via internet
1, 2
Browser showing web document
Client Computer
Web Server
3
44
10
5. Web server locates the applet
6. Sends the applet code to the web browser
7. Through internet it is downloaded to client
8. Applet is executed
Fig. 53.3 Applet downloading
Web Server Transmits Applet along with HTML
1, 2
Browser showing web document
3
Client Computer
44
5
567
8
HTML, applets etc
11
Some Points About Applets
• Applets do not use main() method• They run in a browser• They cannot read or write the files from the
local system• Applets cannot run any other program from the
local computer
12
Some Points About Applets contd..
• Applets are restricted from using libraries from other languages such as C or C++
• They cannot communicate with other servers on the local network
13
Discussion
• What are the differences between applications and applets ?
Access local files
main() method
Can access
Applications Applets
Needed Not needed
Run stand-alone Possible Not possible
GUI based
Cannot access
Run local programs Can run Cannot run
Internet connection Needed for Remote applet
Generally not needed
GUI May or may not
14
Summary
• Java programs are two types• application• applet
• Java applications are the console based programs• Applets are web enabled internet applications• Two types of applets
• Local applets• Remote applets
15
Quiz
1. Applets are console based applications
1. true
2. false
16
Quiz contd..
2. Internet browser runs Java applets
1. true
2. false
17
3. Java applications are web enabled internet applications
1. true
2. false
Quiz contd..
18
Frequently Asked Questions
• Explain about Java applets• List the differences between applets and
applications