A Simple Java Applet
An Applet is a small program that can be sent across the Internet and interpreted on a client machine. To give permission for remote access it must be a public class. Typically it is a class that inherits and/or defines a special set of functions needed to run an applet. These are part of the class Applet. So all Java applets are public classes that extend Applet.
You can not run a Java applet unless it is also an application or you have a WWW page that refers to it.
The page needs HTML like the following to call the compiled code, in the same directory:
Here is a suitable piece of HTML to test a simple HelloWorld class:
The code for the HelloWorld applet has to be a public class called "HelloWorld" that extends Applet and is in in a Java file called:
Here is the Java code:
The Applet is compiled just like any other program:
This will generate a set of files with extension/suffix ".class". Notice that the compiler forces you to name the file "HelloWorld.java", the Class "HelloWorld", and generates the binary bytecode in a file called "HelloWorld.class". Sun has written a special program to test applets in page:
However you can not use 'java' to run the HelloWorld class - it has no 'main'. Neither can 'java' "run" the WWW pages like the test.HelloWorld.html file.
How to Disable View Source in HTML page
How can I disable the view source option in an HTML page.Will it be possible to disable the view source option in the pop up window which appears when we click the right mouse button
Re: A Simple Java Applet
|All times are GMT +5.5. The time now is 17:50.|