It has been a long time since Java was introduced and Java is no longer the darling it once was in the web-app arena or applets; partly because much of its functionality has now been replaced by Flash and Javascript.  Although Java is still a force in the back-end/server side and enterprise arena, you don’t see much Java applets around on the web nowadays.   Lately there are renewed interest for Java because of Android but that’s another story.

For a long time I have been using Microsoft Visual J++ and Symantec Visual Cafe to create applets. Those two products have been dead for a while now and I finally to convert some of my existing applets to Eclipse.  I  found it to be a pleasure to use for Java applet development. Of course Eclipse was originally built as an IDE for Java, so why did it take me so long to switch?  Who knows?  Comfort-zone, no-time, etc.

Anyway, here’s a short guide to converting or creating applet in Eclipse.

The Eclipse version I use is shown below:

Importing Existing Project

In general, importing an existing project is straightforward.  Create a new project (File->New->Java Project) or select Java Project from the list. Enter the desired project name, and select Create From Existing Source, then browse to your existing directory.

The project will be created and files in the directory will be listed.

If there are unused .java files lying around in your project directory, back them up and remove from the list, because Eclipse will likely to complain with error(s).

Running The Applet

Goto menu > Run->Run As->Java Applet.

Adding Parameters

Goto menu > Run-> Run Configurations.

Chose the main class in the Main tab (if not already selected by default).  Add parameters in the Parameters tab.  Applet dimensions is also specified in the Parameters tab.

Creating JAR

Creating JAR file for Applet is straightforward although the process can be confusing.

First, make sure the project is selected in the Eclipse Package Explorer.  Then click File->Export to show this dialog below:

Select JAR file from that list, click Next.

This dialog will appear.

You should uncheck .classpath and .project since they are Eclipse project definitions.

Click Next and this dialog will appear:

Depending on the JDK, your code may produce warning and errors which wasn’t present on older JDKs.  I’d advise correcting them before building JAR files, but if you want to ignore them, then click Next.

This final dialog usually throws users off.   In that if you try to Browse the Main class field nothing is shown (there’s no class to select).  In fact, for Applets, you do not need to specify anything there, so you can leave the Main class field blank and click Finish.

Leave a Reply