Download Applets in Java

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Dependency injection wikipedia , lookup

Falcon (programming language) wikipedia , lookup

Java performance wikipedia , lookup

Application Interface Specification wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Java (programming language) wikipedia , lookup

AppleScript wikipedia , lookup

Transcript
Client-Server applications
Introduction to Java Applets
Client-server architectures
Why do Applets exist?
What can an Applet do?
What are they used for?
Some technical details
Conclusion
[email protected]
Client-Server applications
Simple client-server architecture
Servers may provide different types of services
simultaneously to many clients
Clients are software entities with a network
connection to the server
Clients vary in their capabilities – some have very
little in the way of resources and are considered
“thin”
[email protected]
Client-Server applications
Thin Client systems
Clients may be “thin”, for example a simple
information terminal in a library
or perhaps a mobile handheld device
Thin client systems assume that the bulk of the work
is done at the server
A thin client is little more than a screen and userinput device(s)
[email protected]
Client-Server applications
Client-Server on the Web
Many clients are not thin
Desktop computer systems with an Internet
connection may be more powerful than the server
It is possible to off-load much of the computing work
from the server to the client – better for scalability
In such cases, the client downloads and runs an
application to do work locally
[email protected]
Client-Server applications
Java client-side solutions
Java is a network-centric programming language
It has a number of solutions for client-side
programming
Applets – limited applications that run in a browser
WebStart applications – desktop applications with security
restrictions that can be launched from a web page
Low-level programming of completely general, unrestricted
network applications
[email protected]
Client-Server applications
Why do Applets exist?
In 1995, Java became available as a network-aware
programming language
Applets were part of the language, designed to add
complex functionality to Web pages
At the time, Applets were the only way to program
multimedia on a Web page!
Now competes with Flash, SVG and others
[email protected]
Client-Server applications
Why do Applets exist?
Applets provide trusted, secure, portable
functionality
Cached Applets can be run off-line
Applets allow complex calculations to be run on the
client machine, including;
encryption and secure communication
rapid data communication
interactive graphics
[email protected]
Client-Server applications
What can an Applet do?
Applets are used for lots of tasks;
Online discussions and communication boards
Online document editing
Banking front-ends
Scientific visualisation, e.g. molecule viewers
Advertising (although nearly all Flash now)
Interactive games in 2D and 3D
[email protected]
Client-Server applications
Technical Details
Applets are written in standard Java
Applets are not “complete” applications – they plug
into a browser
Applets can be assumed to have graphics capability
Applets run in a “sandbox” security environment,
giving them extremely limited access to the
resources of the local machine [usually a good thing!]
[email protected]
Client-Server applications
Technical Details
To make an Applet we write a class that extends
Applet (or extends Japplet, the more advanced
Swing-based version)
Then we write code to override some of the four key
methods
These are init(), start(), stop() and destroy()
There is no public static void main(String[] args)
[email protected]
Client-Server applications
Applet methods
Typically we would write code to initialise the Applet
in public void init()
When the Applet becomes visible, the browser will
invoke public void start(), so this is where we
“activate” the program (e.g. start an animation
running)
If the Applet is made invisible we have public void
stop() which turns off animations, sounds etc.
[email protected]
Client-Server applications
Conclusion
Clients and servers vary in their needs an
capabilities
Applets exist to provide rich client capability
Applets can be used as portable, security-limited
applications
For more information, see: Wikipedia on Applets,
Client-server and also Sun's Applet overview
[email protected]
Client-Server applications
Practical notes
You need to compile the .java files on the schedule
into a .class file
Need a HTML to call the .class files
Applets have no main method and so cannot run on their
own
Two examples follow to demonstrate
Free Applets out on the web but beware!
[email protected]
Client-Server applications
HTML wrapper
[email protected]
Client-Server applications
Examples running
[email protected]
Client-Server applications
HTML wrapper
[email protected]
Client-Server applications
Examples running
[email protected]