Summary of Class Presentation for June 9, 1999 We started by discussing the two different ways in which applications and applets are developed. If you download and install the Sun Java SDK as specified in the readme file that is part of the download, you follow these steps for applications: 1. Use a text editor to enter the program text as one or more text-only files. These files must be named for the public class each contains with extension .java 2. Invoke javac from the MS-DOS command prompt to compile the .java files into bytecode files (one for each class) into .class files. 3. Execute the .class files using the java command to invoke the Java runtime interpreter that interprets the bytecodes. Of course, if you downloaded and installed one of the three shareware integrated development environments mentioned in the course syllabus, that environment has commands to handle all of this. For applets the procedure is different: 1. Use a text editor to enter the program text as one or more text-only files. These files must be named for the public class each contains with extension .java. 2. Use javac as above to compile into .class files. 3. Write an html description for the web page that will contain' the applet using the html command. 4. Load the web page into a browser. The browser will load and start the applet as it interprets the html. Differences between applets and applications: 1. applications have a main method within a public class. This is where execution begins. applets use an API (application programming interface) to interact with the browser: a. init() called by browser when the applet is first loaded into memory b. start() called by the browser whenever the web page containing the applet becomes the top web page c. stop() called by the browser whenever the web page containing the applet stops being the top web page d. destroy() called by the browser just before the browser terminates execution normally. e. paint( Graphics g ) called indirectly by the browser whenever the page portion controlled by the applet must be redrawn. Can be called by applet code to force a redraw 2. applications can access any files, web sites, or databases accessible to their user. Applets execute in a sandbox that restricts their access to ensure that untrusted applets cannot modify or affect other software. 3. applets extend (inherit from) the class applet. Application classes do not explicitly extend any other classes unless the writer needs them to. We examined several example programs, both applications and applets together with the needed HTML code to use an applet.