Applet Exporter and Signer for Processing 2
First start Processing and open the sketch you want to export. From the menus select Tools | Applet Export and Signer. The tool will first check to make sure the editor is in JAVA mode, it then gets the sketch renderer and size from your code. If the editor is not in JAVA mode or the renderer is not JAVA2D (default renderer) then the tool will terminate after displaying an error message. If the tool cannot get the sketch size then a warning dialog is displayed and you will have to enter the size manually into the Export Dialog window.
The Export Dialog window provides a number of export options to you. The main edit area is the narrative that will be displayed in the web page. It gets this text from the first Javadoc block comment in your sketch code. (A Javadoc comment is one surrounded by /** */ tags) You can edit this text to suit yourself, even include standard HTML tags, but any changes are not stored in your sketch code.
The first option is the HTML template to be used for the webpage created. There are 2 choices, the first is 'Processing 1.5.1', if you plan to upload the applet to OpenProcessing then use this one. The html created with the other choice, the 'Tool Template', is less verbose and so it is easier to identify the bits responsible for loading the applet.
The Separate Jars option ensures that any jars need by the applet (such as contributed library jars) are kept separate rather than being merged into one jar. Unless you have a pressing need then leave it switched off (single jar option).
Finally the last decision before exporting the applet is whether to sign the applet or not. By default remote Java applets are not allowed to access local computer resources, if your applet needs to do this then it has to be signed. An example would be an applet designed to upload files to the web server. If you tick the box the Signing Dialog window will appear after the applet has been exported.
To sign an applet requires two files which only come with a JDK (Java Development Kit) so if you don't have a JDK head over to Oracle and get one.
The first thing to notice are the 2 pink KEYTOOL and JARSIGNER boxes. They are pink because the tool does not know where the two files used to sign applets are. Click on the browse button and find the folder where the JDK has been installed on your computer, either select this folder (or better still the bin folder inside it). The tool will look in this folder and sub folders recursively for the two files and if found the boxes will turn green.
On windows look in the folder C:/Program Files/Java/
On Mac OSX look in the folder /System/Library/Java/JavaVirtualMachines/
The big panel on the left panel shows information about the person/organisation signing this applet, simply change the values in these boxes to suit yourself.
Now you are ready simply click on the Sign Applet button. The actual process can take some time to complete (depends on your system and the number / size of jars to sign but should be no more than a couple of minutes). A box will appear above the signing button will appear giving you progress information. The location of the two files and the certificate information will also be remembered for the next time you use the tool.
Finally a window will open showing the exported applet folder, simply double click on the index.html file to see your applet in action.