Basic HTML version of Foils prepared 18 May 97

Foil 6 Java Applets

From Java Tutorial - Spring 1997 Part II: Java Language and Object-Oriented Concepts Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


1 Java applets are classes written in Java which are intended not to run as stand-alone programs (as applications do) but as subprograms of a browser which is already managing a window.
2 Applets should NOT have main method but rather init, start, paint etc. for displaying on the browser window
3 The applet should be run through javac compiler getting a .class file as before: javac MyApplet.java
4 Also create an HTML file (say MyApplet.html) with an applet tag.
5 Two ways to run an applet:
  • If you have JDK on one's machine, one can run the applet with appletviewer
    • appletviewer MyApplet.html
  • Alternatively, run Netscape 2.0/3.0 or Internet Explorer essentially anywhere, point the browser at MyApplet.html, and applet is downloaded from the webserver and run by Java interpreter built into the browser. This requires that the .html and .class files are located in the document space of the web server.
6 This way we can compile on places with JDK installed but run almost anywhere!

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Thu Jan 8 1998