SlideShare a Scribd company logo
01/30/15 Distributed Computing, M. L. Liu 1
Java applets
M. L. Liu
01/30/15 Distributed Computing, M. L. Liu2
Introduction
Java applets are one of three kinds of Java
programs:
 An application is a standalone program that can be
invoked from the command line.
 An applet is a program that runs in the context of a
browser session.
 A servlet is a program that is invoked on demand on a
server program and that runs in the context of a web
server process.
01/30/15 Distributed Computing, M. L. Liu3
Applets, web page, client, server
 Applets are programs stored on a web server, similar to web pages.
 When an applet is referred to in a web page that has been fetched and
processed by a browser, the browser generates a request to fetch (or
download) the applet program, then executes the program in the browser’s
execution context, on the client host.
< a p p l e t c o d e = H e l l o W o r l d . c l a s s < / a p p l e t >
...
...
H e l l o W o r l d . c l a s s
s e r v e r h o s t
w e b s e r v e r
m y W e b P a g e . h t m l
b r o w s e r h o s t
b r o w s e r
r e q e u s t f o r
m y W e b P a g e . h t m l
m y W e b P a g e . h t m l
r e q u e s t f o r
H e l l o W o r l d c l a s s
H e l l o W o r l d . c l a s s
H e l l o W o r l d . c l a s s
01/30/15 Distributed Computing, M. L. Liu4
Applet Execution - 1
 An applet program is a written as a subclass of the
java.Applet class or the javax.swing.Japplet class.
There is no main method: you must override the
start method. Applet objects uses AWT for graphics.
JApplet uses SWING.
 It is a Grapics object that runs in a Thread object, so
every applet can perform graphics, and runs in
parallel to the browser process.
01/30/15 Distributed Computing, M. L. Liu5
Applet Execution
 When the applet is loaded, these methods are automatically
invoked in order:
 the init( ) method is invoked by the Java Virtual Machine.
 The start( ) method
 The paint( ) method.
 The applet is now running and rendered on the web page.
 You program the start( ) method and the paint( ) method for
your application, and invoke a repaint call to re-render the
graphics, if necessary.
 At the end of the execution, the stop( ) method is invoked,
followed by the destry( ) method to deallocate the applet’s
resources.
01/30/15 Distributed Computing, M. L. Liu6
Applet Security
http://java.sun.com/docs/books/tutorial/applet/overview/
For security reasons, applets that are loaded over
the network have several restrictions.
 an applet cannot ordinarily read or write files
on the computer that it's executing on.
 an applet cannot make network connections
except to the host that it came from.
01/30/15 Distributed Computing, M. L. Liu7
HTML tags for applets - 1
<APPLET specifies the beginning of the HTML applet code
CODE="demoxx.class" is the actual name of the applet (usually a
'class' file)
CODEBASE="demos/" is the location of the applet (relative as here,
or a full URL)
NAME="smily" the name you want to give to this instance of the
applet on this page
WIDTH="100" the physical width of the applet on your page
HEIGHT="50" the physical height of the applet on your page
ALIGN="Top" where to align the applet within its page space (top,
bottom, center)
01/30/15 Distributed Computing, M. L. Liu8
HTML tags for applets - 2
<PARAM specifies a parameter that can be passed to the applet
NAME=“name1" the name known internally by the applet in order to
receive this parameter
VALUE="000000" the value you want to pass for this parameter
> end of this parameter
<PARAM specifies a parameter that can be passed to the applet (applet
specific)
NAME=“name2" the name known internally by the applet in order to
receive this parameter
VALUE="ffffff" the value you want to pass for this parameter
> end of this parameter
</APPLET> specifies the end of the HTML applet code
01/30/15 Distributed Computing, M. L. Liu9
The HelloWorld Applet
<HTML>
<BODY>
<APPLET code=hello.class width=900
height=300>
</APPLET>
</BODY>
</HTML>
// applet to display a message in a
window
import java.awt.*;
import java.applet.*;
public class hello extends Applet{
public void init( ){
setBackground(Color.yellow);
}
public void paint(Graphics g){
final int FONT_SIZE = 42;
Font font = new
Font("Serif", Font.BOLD,
FONT_SIZE);
// set font, and color and display
message on
// the screen at position 250,150
g.setFont(font);
g.setColor(Color.blue);
// The message in the next line is
the one you will see
g.drawString("Hello,
world!",250,150);
}
}
01/30/15 Distributed Computing, M. L. Liu10
Advanced Applets
 You can use threads in an applet.
 You can make socket calls in an applet, subject to the security constraints.
S e r v e r h o s t C l i e n t h o s t
H T T P s e r v e r b r o w s e r
a p p l e t
H o s t X
a p p le t d o w n lo a d
c o n n e c t io n r e q u e s t
c o n n e c t io n r e q u e s t
f o r b id d e n
a llo w e ds e r v e r Y
s e r v e r Z
01/30/15 Distributed Computing, M. L. Liu11
Proxy server
A proxy server can be used to circumvent the security constraints.
S e r v e r h o s t C l i e n t h o s t
H T T P s e r v e r b r o w s e r
a p p l e t
H o s t X
a p p le t d o w n lo a d
c o n n e c t io n r e q u e s t
s e r v e r Y
s e r v e r Z
c o n n e c t io n r e q u e s t
01/30/15 Distributed Computing, M. L. Liu12
Summary
 An applet is a Java class
 Its code is downloaded from a web server
 It is run in the browser’s environment on the client host
 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

More Related Content

What's hot (20)

PPTX
Java constructors
QUONTRASOLUTIONS
 
PDF
Applet in java
Jancypriya M
 
PPT
Java Socket Programming
Vipin Yadav
 
PPTX
JAVA ENVIRONMENT
josemachoco
 
PPTX
Applets in java
Wani Zahoor
 
PDF
Constants, Variables and Data Types in Java
Abhilash Nair
 
PPTX
Assemblies
Janas Khan
 
PPTX
java interface and packages
VINOTH R
 
PPT
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
PDF
Introduction to java technology
Indika Munaweera Kankanamge
 
PDF
Java I/O
Jussi Pohjolainen
 
PPTX
Constructor in java
SIVASHANKARIRAJAN
 
PDF
Init of Android
Tetsuyuki Kobayashi
 
PPTX
Pure virtual function and abstract class
Amit Trivedi
 
PPTX
MULTI THREADING IN JAVA
VINOTH R
 
PPTX
Functions in c++
Rokonuzzaman Rony
 
PPTX
Exception handling
PhD Research Scholar
 
PPTX
Java swing
Apurbo Datta
 
PDF
Android Fragment
Kan-Han (John) Lu
 
Java constructors
QUONTRASOLUTIONS
 
Applet in java
Jancypriya M
 
Java Socket Programming
Vipin Yadav
 
JAVA ENVIRONMENT
josemachoco
 
Applets in java
Wani Zahoor
 
Constants, Variables and Data Types in Java
Abhilash Nair
 
Assemblies
Janas Khan
 
java interface and packages
VINOTH R
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Introduction to java technology
Indika Munaweera Kankanamge
 
Constructor in java
SIVASHANKARIRAJAN
 
Init of Android
Tetsuyuki Kobayashi
 
Pure virtual function and abstract class
Amit Trivedi
 
MULTI THREADING IN JAVA
VINOTH R
 
Functions in c++
Rokonuzzaman Rony
 
Exception handling
PhD Research Scholar
 
Java swing
Apurbo Datta
 
Android Fragment
Kan-Han (John) Lu
 

Viewers also liked (20)

PPS
Java applets
Srinath Dhayalamoorthy
 
PDF
27 applet programming
Ravindra Rathore
 
PPT
Applet Architecture - Introducing Java Applets
amitksaha
 
PPT
Java: Java Applets
Tareq Hasan
 
PPTX
Applet java
Jorge Luis Tinoco
 
PPT
Java applets
Khan Mac-arther
 
PPTX
6.applet programming in java
Deepak Sharma
 
PPTX
Java Applets
Danial Mirza
 
PDF
Java Applet and Graphics
Abdul Rahman Sherzad
 
PPT
Java applet
Arati Gadgil
 
PPT
Appl clas nd architect.56
myrajendra
 
PPTX
L18 applets
teach4uin
 
PPT
Java swing
Nataraj Dg
 
PPT
Java Swing
Shraddha
 
PDF
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PPT
java swing
vannarith
 
PPTX
Java Swing
Komal Gandhi
 
PPTX
Applet features
myrajendra
 
PPT
Java Applet
Athharul Haq
 
27 applet programming
Ravindra Rathore
 
Applet Architecture - Introducing Java Applets
amitksaha
 
Java: Java Applets
Tareq Hasan
 
Applet java
Jorge Luis Tinoco
 
Java applets
Khan Mac-arther
 
6.applet programming in java
Deepak Sharma
 
Java Applets
Danial Mirza
 
Java Applet and Graphics
Abdul Rahman Sherzad
 
Java applet
Arati Gadgil
 
Appl clas nd architect.56
myrajendra
 
L18 applets
teach4uin
 
Java swing
Nataraj Dg
 
Java Swing
Shraddha
 
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
java swing
vannarith
 
Java Swing
Komal Gandhi
 
Applet features
myrajendra
 
Java Applet
Athharul Haq
 
Ad

Similar to Java applets (20)

PPT
Jsp applet
Sanoj Kumar
 
PPTX
Applet Programming in Advance Java Programming
jayshah562401
 
PDF
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
PDF
UNIT-1-AJAVA.pdf
PriyanshiPrajapati27
 
PPT
Basicsofapplets 53-130303003217-phpapp02
Swati Jadhav
 
PPT
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
PPTX
Applet intro
Nitin Birari
 
PPTX
3. applets
AnusAhmad
 
PPTX
Appletjava
DEEPIKA T
 
DOCX
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
PPTX
MSBTE Computer Engineering Java applet.pptx
kunalgaikwad1705
 
PPT
JAVA APPLET BASICS
Shanid Malayil
 
PPT
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
PPTX
Applet.pptx
LakachewYezihalem
 
PDF
Java applet basics
Sunil Pandey
 
PPT
Applets
SanthiNivas
 
PPTX
Introduction To Applets methods and simple examples
MsPariyalNituLaxman
 
PPTX
applet.pptx
SachinBhosale73
 
PPTX
Applets in Java. Learn java program with applets
halaplay385
 
PPTX
Java applet
Elizabeth alexander
 
Jsp applet
Sanoj Kumar
 
Applet Programming in Advance Java Programming
jayshah562401
 
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
UNIT-1-AJAVA.pdf
PriyanshiPrajapati27
 
Basicsofapplets 53-130303003217-phpapp02
Swati Jadhav
 
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
Applet intro
Nitin Birari
 
3. applets
AnusAhmad
 
Appletjava
DEEPIKA T
 
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
MSBTE Computer Engineering Java applet.pptx
kunalgaikwad1705
 
JAVA APPLET BASICS
Shanid Malayil
 
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
Applet.pptx
LakachewYezihalem
 
Java applet basics
Sunil Pandey
 
Applets
SanthiNivas
 
Introduction To Applets methods and simple examples
MsPariyalNituLaxman
 
applet.pptx
SachinBhosale73
 
Applets in Java. Learn java program with applets
halaplay385
 
Java applet
Elizabeth alexander
 
Ad

More from lopjuan (9)

PPTX
Chapter 2
lopjuan
 
PPTX
Chapter 3
lopjuan
 
PPTX
Chapter 4 2
lopjuan
 
PPT
Chapter 1
lopjuan
 
PPTX
Chapter 4 1
lopjuan
 
PPT
Java servlets
lopjuan
 
PPT
Chapter10
lopjuan
 
PPT
Web services
lopjuan
 
PPT
Chapter7
lopjuan
 
Chapter 2
lopjuan
 
Chapter 3
lopjuan
 
Chapter 4 2
lopjuan
 
Chapter 1
lopjuan
 
Chapter 4 1
lopjuan
 
Java servlets
lopjuan
 
Chapter10
lopjuan
 
Web services
lopjuan
 
Chapter7
lopjuan
 

Recently uploaded (20)

PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 

Java applets

  • 1. 01/30/15 Distributed Computing, M. L. Liu 1 Java applets M. L. Liu
  • 2. 01/30/15 Distributed Computing, M. L. Liu2 Introduction Java applets are one of three kinds of Java programs:  An application is a standalone program that can be invoked from the command line.  An applet is a program that runs in the context of a browser session.  A servlet is a program that is invoked on demand on a server program and that runs in the context of a web server process.
  • 3. 01/30/15 Distributed Computing, M. L. Liu3 Applets, web page, client, server  Applets are programs stored on a web server, similar to web pages.  When an applet is referred to in a web page that has been fetched and processed by a browser, the browser generates a request to fetch (or download) the applet program, then executes the program in the browser’s execution context, on the client host. < a p p l e t c o d e = H e l l o W o r l d . c l a s s < / a p p l e t > ... ... H e l l o W o r l d . c l a s s s e r v e r h o s t w e b s e r v e r m y W e b P a g e . h t m l b r o w s e r h o s t b r o w s e r r e q e u s t f o r m y W e b P a g e . h t m l m y W e b P a g e . h t m l r e q u e s t f o r H e l l o W o r l d c l a s s H e l l o W o r l d . c l a s s H e l l o W o r l d . c l a s s
  • 4. 01/30/15 Distributed Computing, M. L. Liu4 Applet Execution - 1  An applet program is a written as a subclass of the java.Applet class or the javax.swing.Japplet class. There is no main method: you must override the start method. Applet objects uses AWT for graphics. JApplet uses SWING.  It is a Grapics object that runs in a Thread object, so every applet can perform graphics, and runs in parallel to the browser process.
  • 5. 01/30/15 Distributed Computing, M. L. Liu5 Applet Execution  When the applet is loaded, these methods are automatically invoked in order:  the init( ) method is invoked by the Java Virtual Machine.  The start( ) method  The paint( ) method.  The applet is now running and rendered on the web page.  You program the start( ) method and the paint( ) method for your application, and invoke a repaint call to re-render the graphics, if necessary.  At the end of the execution, the stop( ) method is invoked, followed by the destry( ) method to deallocate the applet’s resources.
  • 6. 01/30/15 Distributed Computing, M. L. Liu6 Applet Security http://java.sun.com/docs/books/tutorial/applet/overview/ For security reasons, applets that are loaded over the network have several restrictions.  an applet cannot ordinarily read or write files on the computer that it's executing on.  an applet cannot make network connections except to the host that it came from.
  • 7. 01/30/15 Distributed Computing, M. L. Liu7 HTML tags for applets - 1 <APPLET specifies the beginning of the HTML applet code CODE="demoxx.class" is the actual name of the applet (usually a 'class' file) CODEBASE="demos/" is the location of the applet (relative as here, or a full URL) NAME="smily" the name you want to give to this instance of the applet on this page WIDTH="100" the physical width of the applet on your page HEIGHT="50" the physical height of the applet on your page ALIGN="Top" where to align the applet within its page space (top, bottom, center)
  • 8. 01/30/15 Distributed Computing, M. L. Liu8 HTML tags for applets - 2 <PARAM specifies a parameter that can be passed to the applet NAME=“name1" the name known internally by the applet in order to receive this parameter VALUE="000000" the value you want to pass for this parameter > end of this parameter <PARAM specifies a parameter that can be passed to the applet (applet specific) NAME=“name2" the name known internally by the applet in order to receive this parameter VALUE="ffffff" the value you want to pass for this parameter > end of this parameter </APPLET> specifies the end of the HTML applet code
  • 9. 01/30/15 Distributed Computing, M. L. Liu9 The HelloWorld Applet <HTML> <BODY> <APPLET code=hello.class width=900 height=300> </APPLET> </BODY> </HTML> // applet to display a message in a window import java.awt.*; import java.applet.*; public class hello extends Applet{ public void init( ){ setBackground(Color.yellow); } public void paint(Graphics g){ final int FONT_SIZE = 42; Font font = new Font("Serif", Font.BOLD, FONT_SIZE); // set font, and color and display message on // the screen at position 250,150 g.setFont(font); g.setColor(Color.blue); // The message in the next line is the one you will see g.drawString("Hello, world!",250,150); } }
  • 10. 01/30/15 Distributed Computing, M. L. Liu10 Advanced Applets  You can use threads in an applet.  You can make socket calls in an applet, subject to the security constraints. S e r v e r h o s t C l i e n t h o s t H T T P s e r v e r b r o w s e r a p p l e t H o s t X a p p le t d o w n lo a d c o n n e c t io n r e q u e s t c o n n e c t io n r e q u e s t f o r b id d e n a llo w e ds e r v e r Y s e r v e r Z
  • 11. 01/30/15 Distributed Computing, M. L. Liu11 Proxy server A proxy server can be used to circumvent the security constraints. S e r v e r h o s t C l i e n t h o s t H T T P s e r v e r b r o w s e r a p p l e t H o s t X a p p le t d o w n lo a d c o n n e c t io n r e q u e s t s e r v e r Y s e r v e r Z c o n n e c t io n r e q u e s t
  • 12. 01/30/15 Distributed Computing, M. L. Liu12 Summary  An applet is a Java class  Its code is downloaded from a web server  It is run in the browser’s environment on the client host  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