130 likes | 249 Views
Introduction. History of Java Applets. Problems with applets The Future. History of Java. Understanding applets can only be done with some background. James Gosling (Green Project) C++ Based. Embedded Systems --- born out of frustration. Java and the Internet.
E N D
Introduction • History of Java • Applets. • Problems with applets • The Future.
History of Java • Understanding applets can only be done with some background. • James Gosling (Green Project) • C++ Based. • Embedded Systems --- born out of frustration.
Java and the Internet • Right time, right place. • Mosaic – the first browser to conceive of the idea to use Java within it. • HotJava – intended for cable T.V. lead the way to the development of the applet.
Applets • Embeddable applications • Intended to be run inside other programs --- web browsers. • Why bother? • Extensibility of HTML. • Markup languages limited in functionality • GUI extensions – cross-platform in this instance.
Applets (2) • How do they work? • Differently from Java! • No psvm() • Java VM essential (has issues though). • The life-cycle: • init() ---> [ start() <---> start() ] [<-- R] --> destroy() • (R): repeated whenever page left, re-entered.
Applets (3) • Example: • <html> • <head><title>Wow. My First Applet</title></head> • <body> • <applet code=”mfa.class” width=500 height=100></applet> • [.....] • </body> • </html>
Applets (4) • Example (Java): • import java.applet.*; • import java.awt.*; • public class AV extends Applet { • int count = 0; • Color spect[] = new Color[3]; • public void init() • { • spect[0] = Color.red; • spect[1] = Color.green; • spect[2] = Color.blue; • } • public void start() • { • count++; • } • public void paint(Graphics g) • { • g.setColor(spect[count%3]); // Change colour. • g.drawString("Applet DEMO: "+count,10,20); • } • }
Applets (4) • Output:
Applets: Problems • This is Java – of course there are problems. • JVM – costly on the client. • Different web browsers, different ideas • Netscape versus Internet Exploder – remember that? • Proprietry DOMs – how do you know which is which, and should it be down to the Java Applet to know? • Security – overloading, browser-crashes, etc.
Applets: Problems (2) • Oversight – does the richness Applets provide necessitate their use? • JVM compatability issues: Flash all the way... • (I hope not – that sucks as much as Java does) • JVM startup times are huge – and for what? • Applets tend to be abused by site developers to provide flashy animations that is unwelcome sometimes.
Applets: API • Yes, that's right – there's an interface to Applets. • There wasn't much of one to begin with. • There is now though – and in its current state allows for extendability in the same way one would use a normal Java Application.
The Future • Applets never really caught on. • But that's OK. Really... • AJAX (Asynchronous JavaScript And XML). • Remove the presentation and the content. • Shift the processing to the sever, rather than the client (hence asynchronous). • RoR – Ruby on Rails – an extensible framework written in Ruby. Beats the pants off Java, anyday.
References http://java.sun.com http://c2.com/cgi/wiki http://www.bookrags.com/sciences/computerscience/java-applets-csci-04.html http://www.rubyonrails.org Books: “Big Java”, Horstmann, J. 2000