For both of these you need to compile your classes first. By convention, source files for classes in Java are stored in files with a .java extension. So, for a class called Helloworld there should be a file named Helloworld.java. To compile this class do:
Note that javac allows you one public class per file and insists that the file have the same name as the class. If the filename and class do not match, javac issues a compilation error. A single file can contain multiple classes, as long as only one of the classes is public .
You should avoid packing lots of classes into a single file.
Applets run on browsers (Appletviewer, Mozilla Firefox, IE, etc.)
To run from your machine and simulate what will happen
on a web page, you can use appletviewer to test your applets.
To do this you need a classname.html file
Here is an example of HelloWorld.html
Here is the code for the definition of the class: HelloWorld.java that does not use Swing
To Run (after compilation):
To Run (after compilation):
For compilation, you can use various options with javac. One
useful option is -d where you specify an alternative directory
for storing the class files it generates.
This would have been cool, if it worked...sigh
Here is the code for the definition of the class: HelloSwingApplet.java that does use Swing
note if HelloWorld is in a specified package then
javac with the -d option will automatically create any directories needed to store the class file in the appropriate place (i.e, subdirectories mirroring the package name
See javac - The Java Compiler page
For the java command, one has options as well.
In fact, here is the JDK Tools and Utilities page with Basic Tools, Security Tools, etc. links