18
1 Basics of Applet

Basics of applets.53

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Basics of applets.53

1

Basics of Applet

Page 2: Basics of applets.53

2

Objective

On completion of this period, you will be able to learn

• Basics of applet

Page 3: Basics of applets.53

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

Page 4: Basics of applets.53

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’

Page 5: Basics of applets.53

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)

Page 6: Basics of applets.53

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

Page 7: Basics of applets.53

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

Page 8: Basics of applets.53

8

Loading of Remote Applet

Internet

Local Computer (Client)

Remote Computer (Server)

Remote Applet

Fig. 53.1 Loading of remote applet

Applet

Page 9: Basics of applets.53

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

Page 10: Basics of applets.53

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

Page 11: Basics of applets.53

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

Page 12: Basics of applets.53

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

Page 13: Basics of applets.53

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

Page 14: Basics of applets.53

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

Page 15: Basics of applets.53

15

Quiz

1. Applets are console based applications

1. true

2. false

Page 16: Basics of applets.53

16

Quiz contd..

2. Internet browser runs Java applets

1. true

2. false

Page 17: Basics of applets.53

17

3. Java applications are web enabled internet applications

1. true

2. false

Quiz contd..

Page 18: Basics of applets.53

18

Frequently Asked Questions

• Explain about Java applets• List the differences between applets and

applications