In Visual Studio, select menu item File > New > Project, highlight Java Applet, give it a name then click the OK button. This gives you a default applet from which to start. You can also paste code into the default project to run demonstrations. Note that namespaces comprise lower-case letters only. We provide several examples of short project files that you can use to compile applets using the command-line compiler.

The output of compilation of applets is a jar (Java archive) file. There is a tool named jar in the Java SDK that you can use as follows.

  • jar tvf MyClasses.jar lists the contents of MyClasses.jar.
  • jar cvf *.class makes an archive of all the .class files in the current folder.
  • jar xvf MyClasses.jar Main.class extracts Main.class from the archive.
For examples of extracting classes from archives and creating new archives follow the link to "Combining Jar Files".

To run applets in HTML files you need a web browser that can be Java-enabled. You might be able to use the appletviewer in the Java SDK by supplying it with the URL of the web page containing the applet.

An Applet inherits many useful methods from java.awt.Component e.g. addKeyListener addMouseListener, addMouseMotionListener, getHeight, getWidth, getSize, setBackground, setFont, setForeground. Be on the lookout for these methods when reading the source code of the examples.

We are grateful to Dharmesh Tailor for converting ten of these applets from the original Java code and for writing an effective demonstration himself. You can see screenshots of the original applets at Professor Michael McGuffin's new site. (Brian Long's conversions of a few of these applets are included in the download of Oxygene for Java from RemObjects).

Note: The mouse demonstrations that we begin with show you the potential for creating great games and other interactive applets. We advise you to start off by making changes to the line drawing demonstration, which is the most straightforward.
Programming - a skill for life!

Console, frame-based and Android applications, applets, game development, networking and language features