Share Core Files
From Processing
Most processing jar files are largely the same as each other. They all contain a copy of all the stuff in core.jar, as well as your applet and it's data.
However with Processing-0113 it's now possible to get processing to export seperate .jar files so you can slimline your uploads to save on disk space. It should be noted that this does not reduce the total file size that a visitor will download to see your applet, just let you keep things slim on the server.
How
There are two ways to get processing to export an applet with multiple jar files, one is to use opengl, then it happens automatically, the other is to go to open the Preferences menu in processing, and select "Use multiple .jar files when exporting applets"
When you export your sketch to an applet, it will create a directory as before, but with more than one .jar file, normally MySketch.jar and core.jar plus any extra libraries you may have used, e.g. OpenGL.
You need to take a copy of core.jar, plus any library .jar files you use in your sketches, and put them all into one directory on your web server, for example I chose a directory called "core" and put all the non-sketch jar files in there.
Now all you need to do when you create a sketch is upload the sketch.jar file, and an edited copy of the index.html file:
As created by processing:
<applet code="MySketch" archive="MySketch.jar,core.jar" width="400" height="400" mayscript="true">Changed version:
<applet code="MySketch" archive="../MySketchDirectory/MySketch.jar,core.jar"
codebase="../core/" width="400" height="400" mayscript="true">The "codebase" parameter tells Java that the files actually reside in a different directory, in this case ../code/ (this could be an absolute URL I believe) and it will use that as the default path for all the files, when there's lots, this makes things easier. However, since Java is now looking in the code/ directory for all the files, we have to tell it that the MySketch.jar is actually in ../MySketchDirectory/
If you only have a few sketches on your website, this is probbaly not the hack for you, but if you've got lots, this could save you quite a lot of diskspace, especially if you're creating lots of OpenGL applets.
Caveat
When processing gets updated, all you need to do is upload the new core.jar, and magically all your sketches will now be using the new version. This may cause problems, or it may fix them, depending on the changes made between the versions.
So if you have any sketches that worked previously, you may want to test them with the new core.jar before overwriting the file on the server.
OpenGL Example
For an OpenGL applet, where previously we had:
<applet code="com.sun.opengl.util.JOGLAppletLauncher"
archive="jogl.jar,MySketch.jar"
width="800" height="600" mayscript="true">We will now have:
<applet code="com.sun.opengl.util.JOGLAppletLauncher"
archive="MySketch.jar,opengl.jar,jogl.jar,core.jar"
width="800" height="600"
mayscript="true">And this should become:
<applet code="com.sun.opengl.util.JOGLAppletLauncher"
archive="../MySketchDir/MySketch.jar,opengl.jar,jogl.jar,core.jar"
codebase="../core/"
width="800" height="600" mayscript="true">Note that now we only need one central copy of all the jogl jar files (including the native ones) core.jar and opengl.jar, meaning we can save a lot of space per sketch.