JAVA Applet You may have choosen to write your program in Java. Here is an example of changing a java program into java applet that can be run directly on browsers. Applications and applets start program execution in different ways; an application has a main() method and an applet has a init() method inititiated by the browser.
Compile the .java file in command line: javac HelloWorld.java Then it is ready to be embed it into a html file. Two HTML tags are used to specify a java applet. The <APPLET> tag basically just tells the browser what applet.class file to use, and how wide and high the applet should be. There are additional (optional) attributes you can set up, too; but in simplest use, that's all there is to this tag, and usually all you will need. The <PARAM> tag names a parameter fir the JAVA applet, and provides the VALUE for it. Note that calling different applets may require different number of PARAM tags according to the number of arguments required by the applet. Here's the framework of a simple HTML tag set for putting an applet into your page:
Here is the example HTML we use to call the hello world applet. Since the applet does not expect any parameters, there is no PARAM field within the APPLET tags.
The CODE="filename.class" contains the name of the applet's class file. The class file is a small executable which does the real work of the applet. You have to put it under the same directory as the HTML page calling it, or you have to use CODEBASE attribute to specify the directory. Click here to see it working
|