A easy way to run a applet inside a browser..........
Create a simple web page which calls the applet which we have created.........the below code is the html code which is used for calling the applet Hello
html start tag
boby start tag
< /applet > tag must be provided here with the proper src.
body end tag
html end tag
We need to make sure that the applet tag is placed only between the body tags.........
This tells the browser to run the applet Hello.class, and to use an area of the screen 500 pixels wide and 300 high. To create the above web page( incase if you are not familiar with the html language) copy paste the above lines into a text document and save it as Hello.html in the same directory that has Hello.class. At this point your directory should look something like this:
C:\> dir A*.*
03/07/98 08:01p 560 Hello.class
03/07/98 08:01p 199 Hello.html
03/07/98 08:00p 247 Hello.java
3 File(s) 1,006 bytes
157,295,104 bytes free
Now double click on the html file. Your Web browser starts running and displays the applet.
Or
you can use the appletviewer to run the applet:
C:\> appletviewer Hello.html
Sometimes browsers are not set up for applets, or have other problems and as a result of this the browser cant open the applet, a error message is displayed saying that "Failed opening the applet. Make sure that the applet-viewer is in the same directory as java and javac and is more reliable for viewing your applets than a Web brower. However, the appletviewer shows you only the applet part of an HTML file. The other parts (if any) are omitted.

No comments:
Post a Comment