<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Depth-First: Tag java</title>
    <link>http://depth-first.com/articles/tag/java</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>ChemWriter 1.3.1</title>
      <description>&lt;p&gt;&lt;a href="http://metamolecular.com/chemwriter/"&gt;ChemWriter&lt;/a&gt; 1.3.1 can now be &lt;a href="http://metamolecular.com/downloads/"&gt;downloaded&lt;/a&gt;. This version resolves an &lt;tt&gt;&lt;a href="http://metamolecular.com/chemwriter/draw/"&gt;EditorApplet&lt;/a&gt;&lt;/tt&gt; issue in which molfiles containing two or more atoms with exactly the same 2D coordinates were not displayed properly.&lt;/p&gt;

&lt;p&gt;Details are available on the &lt;a href="http://metamolecular.com/blog/2008/06/30/chemwriter-1-3-1-resolves-issue-with-overlapping-atoms/"&gt;Metamolecular Company Blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;ChemWriter is the 2D chemical structure editor designed for Web applications. Lightweight and intuitive, ChemWriter makes an &lt;a href="http://depth-first.com/articles/2007/11/27/chemwriter-chemical-structures-and-the-web"&gt;excellent choice&lt;/a&gt; for both creating and displaying 2D chemical structures on the Web.&lt;/p&gt;</description>
      <pubDate>Mon, 30 Jun 2008 14:54:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:6a2ff3ca-cec8-41bb-a4c1-8e2d002b8b40</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/06/30/chemwriter-1-3-1</link>
      <category>Tools</category>
      <category>chemwriter</category>
      <category>2d</category>
      <category>java</category>
      <category>applet</category>
      <category>structureeditor</category>
    </item>
    <item>
      <title>3D Molecular Visualization on the Web: OpenAstexViewer</title>
      <description>&lt;p&gt;&lt;center&gt;&lt;a href="http://openastexviewer.net/web/"&gt;&lt;img src="http://depth-first.com/demo/20080619/astex.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://openastexviewer.net/web/"&gt;OpenAstexViewer&lt;/a&gt; is an &lt;a href="http://openastexviewer.net/web/license.html"&gt;LGPL-licensed&lt;/a&gt; 3D molecular visualization tool written in Java. With the obfuscated jarfile weighing in at 1 MB, OpenAstexViewer could make a good choice for use in Web applications.&lt;/p&gt;

&lt;p&gt;There are now at least two open source, feature-rich 3D molecular visualization tools written in Java (the other being &lt;a href="http://jmol.sourceforge.net/"&gt;Jmol&lt;/a&gt;). Are there any others?&lt;/p&gt;

&lt;p&gt;Credit: thanks to &lt;a href="http://baoilleach.blogspot.com/2008/06/jmol-gets-competition-openastexviewer.html"&gt;Noel O'Boyle&lt;/a&gt; for spotting this.&lt;/p&gt;</description>
      <pubDate>Thu, 19 Jun 2008 09:04:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:5a17e1c6-770f-48b3-84fe-98c9589ea4b3</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/06/19/3d-molecular-visualization-on-the-web-openastexviewer</link>
      <category>Tools</category>
      <category>3d</category>
      <category>openastexviewer</category>
      <category>visualization</category>
      <category>java</category>
      <category>applet</category>
    </item>
    <item>
      <title>Screencast: Drawing Structures Quickly With ChemWriter</title>
      <description>&lt;p&gt;&lt;center&gt;&lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="499" height="327"&gt; &lt;param name="movie" value="http://content.screencast.com/bootstrap.swf"&gt;&lt;/param&gt; &lt;param name="quality" value="high"&gt;&lt;/param&gt; &lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;/param&gt; &lt;param name="flashVars" value="thumb=http://content.screencast.com/media/fa8ec0ce-c407-4865-bde6-e7516415eeab_b9ab823a-eaff-486a-b654-0eb60b088326_static_0_0_Thumbnail.gif&amp;amp;content=http://content.screencast.com/media/d668e3f9-6130-441e-978a-420d7d267afb_b9ab823a-eaff-486a-b654-0eb60b088326_static_0_0_00000005.swf&amp;amp;width=499&amp;amp;height=327"&gt;&lt;/param&gt; &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt; &lt;param name="scale" value="showall"&gt;&lt;/param&gt; &lt;param name="allowScriptAccess" value="always"&gt;&lt;/param&gt;  &lt;embed src="http://content.screencast.com/bootstrap.swf" quality="high" bgcolor="#FFFFFF" width="499" height="327" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/media/fa8ec0ce-c407-4865-bde6-e7516415eeab_b9ab823a-eaff-486a-b654-0eb60b088326_static_0_0_Thumbnail.gif&amp;amp;content=http://content.screencast.com/media/d668e3f9-6130-441e-978a-420d7d267afb_b9ab823a-eaff-486a-b654-0eb60b088326_static_0_0_00000005.swf&amp;amp;width=499&amp;amp;height=327" allowFullScreen="true" scale="showall"&gt;&lt;/embed&gt; &lt;/object&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;This short video shows how to use &lt;a href="http://metamolecular.com/chemwriter"&gt;ChemWriter&lt;/a&gt; to draw structures quickly with &lt;a href="http://metamolecular.com/articles/chemwriter-keyboard"&gt;keyboard shortcuts&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Wed, 18 Jun 2008 13:55:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:19fa9cb2-e757-4091-aae3-394ff9258046</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/06/18/screencast-drawing-structures-quickly-with-chemwriter</link>
      <category>Tools</category>
      <category>chemwriter</category>
      <category>2d</category>
      <category>java</category>
      <category>screencast</category>
      <category>editor</category>
      <category>chemicalstructure</category>
      <category>jing</category>
    </item>
    <item>
      <title>Better Structure Drawing With ChemWriter 1.3.0</title>
      <description>&lt;p&gt;&lt;a href="http://metamolecular.com/chemwriter"&gt;&lt;img src="http://depth-first.com/demo/20080610/chemwriter_small.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;&lt;a href="http://metamolecular.com/chemwriter/"&gt;ChemWriter&lt;/a&gt; 1.3.0 has been released and is ready for &lt;a href="http://metamolecular.com/downloads/"&gt;download&lt;/a&gt;. This version makes it possible to change the mouse cursor hover radius for more accurate drawing. It also adds a setting to disable heteroatom keyboard shortcut events occurring away from a molecule node, reducing the possibility of an off-atom label being inadvertently drawn.&lt;/p&gt;

&lt;p&gt;For details, see the &lt;a href="http://metamolecular.com/blog/2008/06/16/better-drawing-with-chemwriter-1-3-0/"&gt;Metamolecular Company Blog&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Mon, 16 Jun 2008 16:18:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:9767a41c-4766-41d4-a3db-abf8176ca407</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/06/16/better-structure-drawing-with-chemwriter-1-3-0</link>
      <category>Tools</category>
      <category>chemwriter</category>
      <category>2d</category>
      <category>chemicalstructure</category>
      <category>java</category>
      <category>editor</category>
    </item>
    <item>
      <title>Adobe Flash for Cheminformatics: Fast, Scalable, and Attractive 2D Depiction of Chemical Structures with Vector Graphics</title>
      <description>&lt;p&gt;&lt;a href="http://metamolecular.com/chemwriter"&gt;&lt;img src="http://depth-first.com/demo/20080610/chemwriter_small.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;The previous article in this series &lt;a href="http://depth-first.com/articles/2008/06/06/the-other-vector-graphics-markup-language"&gt;discussed the use of vector graphics markup languages for cheminformatics&lt;/a&gt;, in particular for the display of 2D chemical structures. Although vector graphics are well-suited for creating responsive and appealing cheminformatics Web applications, the lack of universal native browser support makes both &lt;a href="http://en.wikipedia.org/wiki/Scalable_Vector_Graphics"&gt;Scalable Vector Graphics&lt;/a&gt; (SVG) and its cousin &lt;a href="http://www.w3.org/TR/1998/NOTE-VML-19980513"&gt;Vector Markup Language&lt;/a&gt; (VML) unattractive at this time. This article highlights Adobe Flash as a 2D chemical structure renderer for Web applications, and features a fully-functional proof of concept based on the &lt;a href="http://metamolecular.com/chemwriter"&gt;ChemWriter&lt;/a&gt; rendering engine.&lt;/p&gt;

&lt;h4&gt;About Adobe Flash&lt;/h4&gt;

&lt;p&gt;Although Adobe Flash is practically an industry unto itself today, at it's core, Flash is a lightweight vector graphics renderer. Introduced in 1996, the Flash Player can be found on millions of Internet-enable devices today. According to a &lt;a href="http://www.adobe.com/products/player_census/flashplayer/"&gt;study by Adobe&lt;/a&gt;, the Flash Player was running on nearly 99% of Internet-enabled desktops as of March 2008. The player has also found its way onto a host of handheld devices and phones.&lt;/p&gt;

&lt;p&gt;Many technologies have been layered on top of the Flash Player. One of the first was the &lt;a href="http://www.adobe.com/devnet/actionscript/articles/actionscript3_overview.html"&gt;ActionScript&lt;/a&gt; scripting language. More recently, Adobe has introduced &lt;a href="http://depth-first.com/articles/2007/05/25/flex-rich-internet-applications-and-cheminformatics"&gt;Flex&lt;/a&gt;, a full-fledged application development framework.&lt;/p&gt;

&lt;p&gt;Unlike SVG and other vector graphics systems, Flash is ready today, proven, and about as close to universal as is possible on the Web. If you want to do vector graphics on the Web with the most convenient user and developer experience, Flash is your tool.&lt;/p&gt;

&lt;p&gt;But what can Flash do for cheminformatics?&lt;/p&gt;

&lt;h4&gt;A Demonstration&lt;/h4&gt;

&lt;p&gt;The table below is composed of twelve cells, each of which display a chemical structure through the Flash Player.&lt;/p&gt;

&lt;p&gt;&lt;style type="text/css"&gt;
      .cells a {display: block; text-align: center;}
    &lt;/style&gt;
    &lt;table class="cells" cellpadding="3" border="2"&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/bicalutamide.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/bicalutamide.swf" quality="high"
             width="150" height="150" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt;
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/bicalutamide.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/budesonide.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/budesonide.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/budesonide.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/buproprion.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/buproprion.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/buproprion.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/clopidogrel.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/clopidogrel.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/clopidogrel.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/docetaxel.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/docetaxel.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/docetaxel.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/escitalopram.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/escitalopram.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/escitalopram.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/fluticasone.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/fluticasone.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/fluticasone.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/lopinavir.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/lopinavir.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/lopinavir.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/omega_conotoxin_gvia_16132374.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/omega_conotoxin_gvia_16132374.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/omega_conotoxin_gvia_16132374.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/oseltamivir.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/oseltamivir.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/oseltamivir.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/sertraline.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/sertraline.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/sertraline.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
            width="150" height="150"&gt;
      &lt;param name="movie" value="http://depth-first.com/demo/20080610/sildenafil.swf"&gt;
      &lt;embed src="http://depth-first.com/demo/20080610/sildenafil.swf" quality="high"
             width="150" height="150" name="movie" type="application/x-shockwave-flash"
             pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    &lt;/object&gt;
    &lt;a href="http://depth-first.com/demo/20080610/sildenafil.swf"&gt;zoom&lt;/a&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt; &lt;/p&gt;

&lt;p&gt;Several points are worth mention:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Each of the structures can be zoomed by clicking on its 'zoom' link.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each cell contains a lightweight embedded "SWF" file, or "ShockWave File," and the zoomed view displays exactly the same file. No matter how the SWF file is resized, it will always be proportionally-scaled to its smallest dimension and centered.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The size of each SWF file ranges from a low of 563 bytes to a high of 8.5 KB, with an average of around 1.5KB. The larger the molecule, the more space is required. A comparable PNG with a resolution of 150x150 pixels would require on average for each structure about 6-8 KB.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each image was generated from a molfile using a development version of the &lt;a href="http://metamolecular.com/chemwriter"&gt;ChemWriter&lt;/a&gt; rendering engine via the open source &lt;a href="http://www.flagstonesoftware.com/transform/"&gt;Transform SWF&lt;/a&gt; Java toolkit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SWF Files, unlike applets, are highly optimized for multiple instance display on all major platforms and browsers. In every case, startup will be nearly instantaneous and scrolling will be smooth. The performance of Flash should be at least as good as, if not better than, raster images.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;The Right Tool for the Job (is Probably not a Raster Image)&lt;/h4&gt;

&lt;p&gt;One of the first challenges developers of cheminformatics Web applications are faced with is how to render 2D chemical structures. For an overview of the technologies now in use, see the &lt;a href="http://depth-first.com/articles/2008/06/06/the-other-vector-graphics-markup-language"&gt;previous article&lt;/a&gt; in this series. Each option has its own set of trade-offs.&lt;/p&gt;

&lt;p&gt;The most widely-used 2D structure rendering option, raster images, is both inflexible and inefficient. Unlike a vector image, a raster image by definition has only one resolution, which is fixed at creation time. If image dimensions need to change, then all structures must be re-imaged. Given the size of many of today's &lt;a href="http://depth-first.com/articles/2007/01/24/thirty-two-free-chemistry-databases"&gt;chemistry databases&lt;/a&gt;, such a system-wide re-imaging of structures can involve a non-trivial amount of processor power and bandwidth.&lt;/p&gt;

&lt;p&gt;To compensate, many sites store relatively large images, say 300x300 pixel, and then use the HTML &lt;tt&gt;&amp;lt;img&amp;gt;&lt;/tt&gt; tag to shrink it as needed. But this creates problems of its own: both storage and bandwidth requirements are far larger than they need to be, resulting in the need for more powerful server hardware and poorer application scalability. And then there are the application's users, who must wait through a 30KB or higher download for each 2D image.&lt;/p&gt;

&lt;p&gt;A significant number of structures in any compound collection will be so large that even a 300x300 pixel image will be insufficient to render the necessary detail. For example, &lt;a href="http://depth-first.com/articles/2008/05/19/building-chempedia-resizable-structures-with-chemwriter"&gt;a recent Depth-First article&lt;/a&gt; discussed a vector graphics solution this problem within the context of &lt;a href="http://chempedia.com"&gt;Chempedia&lt;/a&gt;, the free chemical encyclopedia. Vector graphics simply eliminate this issue.&lt;/p&gt;

&lt;p&gt;Many cheminformatics applications would benefit from being able to show 50 or more structures at a time, with each structure having a zoom view for closer inspection. To a non-chemist, this might seem unnecessary. But for today's chemists dealing with large chemical catalogs and high-throughput screens, it's not only possible, but a routine part of the practice of chemistry. The raster image approach makes it extremely difficult to meet this important need on the Web. Vector graphics, possibly delivered through the Flash Player, offer a much simpler and more efficient way to do it.&lt;/p&gt;

&lt;p&gt;2D chemical structures are vectorial in nature; using raster images to depict them is in most cases the more costly and lower quality option.&lt;/p&gt;

&lt;h4&gt;Summary&lt;/h4&gt;

&lt;p&gt;Vector graphics are a near-perfect match for the job of depicting 2D chemical structures on the Web. Although there are many vector graphics platforms to choose from, the Flash Player is by far the most universal option. This article has demonstrated a working example of multiple 2D chemical structures rendered as lightweight vector images via the Adobe Flash Player, the first and only such demonstration of which I'm aware.&lt;/p&gt;

&lt;p&gt;The key technologies behind this demonstration are the &lt;a href="http://metamolecular.com/chemwriter"&gt;ChemWriter&lt;/a&gt; rendering engine and the open source Flash developer toolkits available from &lt;a href="http://www.flagstonesoftware.com/transform/"&gt;Flagstone Software&lt;/a&gt;. If you're interested in learning more about how vector graphics and Flash can improve both the user and developer experience in your cheminformatics Web applications, I'd be happy to &lt;a href="http://mailhide.recaptcha.net/d?k=01_5KIPZyZx-bysSnY0HEqIw==&amp;amp;c=9ppCEFFs3OESfeieiRz1LAgTPkQmMhWOQm4RKDRkFI8=" onclick="window.open('http://mailhide.recaptcha.net/d?k=01_5KIPZyZx-bysSnY0HEqIw==&amp;amp;c=9ppCEFFs3OESfeieiRz1LAgTPkQmMhWOQm4RKDRkFI8=', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" title="Reveal this e-mail address"&gt;hear from you&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Tue, 10 Jun 2008 11:05:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:9a0ab422-6515-446f-a0ef-a765519d8dd1</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/06/10/adobe-flash-for-cheminformatics-fast-scalable-and-attractive-2d-depiction-of-chemical-structures-with-vector-graphics</link>
      <category>Tools</category>
      <category>flash</category>
      <category>adobe</category>
      <category>svg</category>
      <category>vml</category>
      <category>chemwriter</category>
      <category>vectorgraphics</category>
      <category>2d</category>
      <category>chemicalstructure</category>
      <category>java</category>
      <category>swf</category>
    </item>
    <item>
      <title>Chempedia.net: Mashing Up PubChem and Wikipedia</title>
      <description>&lt;p&gt;&lt;a href="http://chempedia.com"&gt;&lt;img src="http://chempedia.net/images/global/logo.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;&lt;a href="http://pubchem.ncbi.nlm.nih.gov/"&gt;PubChem&lt;/a&gt; and &lt;a href="http://wikipedia.net"&gt;Wikipedia&lt;/a&gt; represent two of the largest open repositories of chemical information in the world. And they complement each other very nicely. PubChem contains mainly low-level chemical structure information whereas Wikipedia contains free-text descriptions of chemical compounds in the form of &lt;a href="http://depth-first.com/articles/2008/04/02/wikipedia-for-cheminformatics-a-simple-web-api-for-finding-cas-numbers-in-compound-monographs"&gt;compound monographs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Both services offer permission and access to copy and reuse their contents. But neither service is, by itself, nearly as useful as it could be.&lt;/p&gt;

&lt;p&gt;Why not mash them up?&lt;/p&gt;

&lt;p&gt;To explore that question my company, &lt;a href="http://metamolecular.com"&gt;Metamolecular, LLC&lt;/a&gt; has launched &lt;a href="http://chempedia.com"&gt;Chempedia&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To my knowledge, Chempedia represents the first publicly-facing database of compounds to incorporate Wikipedia's collection of organic compound monographs. And it's one of the few cheminformatics services to make use of free-text descriptions generated by individual chemists.&lt;/p&gt;

&lt;p&gt;Chempedia has been somewhat selective about the compounds it includes. To date, it has spidered over 2,500 monographs, combining them with over 300,000 of the most interesting compounds from PubChem. Not every Chempedia.net molecule has a monograph, but now there's a tool that can actually make that absence apparent.&lt;/p&gt;

&lt;p&gt;Chempedia is both an experiment and a service. It's immediately useful for anyone in the business of making or doing things with organic molecules. It's created several unexpected moments of "Oh, that's actually a useful molecule!" It also will serve as a platform to test some of the ideas discussed in Depth-First over the last year or so on the advantages of the Web for collaboration in chemistry.&lt;/p&gt;

&lt;p&gt;Stay tuned for more details about how Chempedia was created and some of its applications in chemistry.&lt;/p&gt;</description>
      <pubDate>Fri, 04 Apr 2008 10:06:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:168432fb-c064-43c2-a60d-728c7c29c406</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/04/04/chempedia-net-mashing-up-pubchem-and-wikipedia</link>
      <category>Tools</category>
      <category>chempedia</category>
      <category>wikipedia</category>
      <category>pubchem</category>
      <category>rails</category>
      <category>ruby</category>
      <category>chemwriter</category>
      <category>applet</category>
      <category>java</category>
      <category>jruby</category>
    </item>
    <item>
      <title>Five Open Tools for 2D Structure Layout (aka Structure Diagram Generation)</title>
      <description>&lt;p&gt;&lt;a href="http://metamolecular.com/chemwriter"&gt;&lt;img src="http://depth-first.com/demo/20070411/difficult.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;Given a molecular representation without 2D coordinates, how would you display a human-readable view?&lt;/p&gt;

&lt;p&gt;This problem can arise in many situations, one of the most common of which is the parsing of &lt;a href="http://depth-first.com/articles/tag/linenotation"&gt;line notations&lt;/a&gt; such as &lt;a href="http://depth-first.com/articles/2007/10/19/easily-convert-iupac-nomenclature-to-smiles-inchi-or-molfile-with-rubidium"&gt;IUPAC nomenclature&lt;/a&gt;, SMILES, or &lt;a href="http://depth-first.com/articles/2007/10/15/an-introduction-to-the-rubidium-cheminforamtics-toolkit-interconvert-smiles-inchi-and-molfile-with-an-open-babel-like-interface"&gt;InChI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And then there are the cases when you have 2D coordinates, but they're &lt;a href="http://depth-first.com/articles/2008/02/12/the-art-and-science-of-chemical-structure-diagrams-double-trouble"&gt;not very aesthetically pleasing&lt;/a&gt;. Maybe the coordinates were created by people either in a hurry or working with low quality editors, or maybe they were generated as distorted 2D projections of 3D coordinates. Whatever the reason, simply having 2D coordinates may not be the same as having &lt;em&gt;good&lt;/em&gt; 2D coordinates.&lt;/p&gt;

&lt;p&gt;Last year, a Depth-First article &lt;a href="http://depth-first.com/articles/2007/04/11/structure-diagram-generation"&gt;discussed the Structure Diagram Generation (SDG) problem&lt;/a&gt; and how it can be solved with Open Source software. Given that nearly a year has passed, it seemed appropriate to revisit the topic.&lt;/p&gt;

&lt;p&gt;The good news is that there are at least four independent Open Source implementations of SDG algorithms, and one potential open database approach. They are, in no particular order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://sourceforge.net/projects/mcdl"&gt;MCDL&lt;/a&gt; Written in Java, the emphasis of this software appears to be facilitating the use of &lt;a href="http://depth-first.com/articles/2006/08/19/a-first-look-at-modular-chemical-descriptor-language-mcdl"&gt;Modular Chemical Descriptor Language&lt;/a&gt;. Unfortunately, no new releases of this intriguing software package have been made in the last year.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://sf.net/projects/cdk"&gt;Chemistry Development Kit (CDK)&lt;/a&gt; This useful package handles about 70-80% of a typical assortment of chemical structures well. The large amount of activity on the CDK project in general makes this a particularly good SDG system to contribute to, especially in the areas of refactoring and handling special cases. See also &lt;a href="http://www.steinbeck-molecular.de/steinblog/index.php/2007/08/14/structure-diagram-generation-sdg-2d-layout-in-the-chemistry-development-kit-part-1/"&gt;Christoph Steinbeck's overview of CDK's layout system&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://bkchem.zirael.org/"&gt;BKChem&lt;/a&gt; A 2D structure editor written in Python. Give it an InChI and it will display the structure, courtesy of SDG. The system worked remarkably well with the molecules I tested. BKChem has also been reported to work in &lt;a href="http://bkchem.zirael.org/batch_mode_en.html"&gt;batch mode&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://www.rdkit.org/"&gt;RDKit&lt;/a&gt; Written in Python and C++, this package is the newest of the bunch. Although &lt;a href="http://sourceforge.net/mailarchive/message.php?msg_id=360844.35824.qm%40web34206.mail.mud.yahoo.com"&gt;I haven't had much luck compiling RDKit&lt;/a&gt;, it still looks quite promising. Any chance of switching to &lt;a href="http://www.gnu.org/software/make/"&gt;make&lt;/a&gt; as a build system?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://pubchem.ncbi.nlm.nih.gov/"&gt;PubChem&lt;/a&gt; PubChem? Maybe. With a database of small molecules now numbering well over ten million, there's a good chance that the molecule for which you need to assign coordinates is already in PubChem. And if it's in PubChem, 2D coordinates have already been assigned. Use an InChI as a hash key, and voila - instant SDG without much software. Given the novelty of large, publicly-available databases of small molecules such as PubChem, this approach may have a great deal of untapped potential.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SDG is one of those issues that can stay off the radar for some only to become an instant, nagging problem with no clear way out. The tools cited here offer an excellent place to begin working toward a comprehensive solution.&lt;/p&gt;</description>
      <pubDate>Wed, 26 Mar 2008 09:11:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:5441d3fc-3dc2-4f2d-b740-5cad16dd454b</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/03/26/five-open-tools-for-2d-structure-layout-aka-structure-diagram-generation</link>
      <category>Tools</category>
      <category>sdg</category>
      <category>2d</category>
      <category>mcdl</category>
      <category>cdk</category>
      <category>bkchem</category>
      <category>rdkit</category>
      <category>pubchem</category>
      <category>coordinates</category>
      <category>java</category>
      <category>python</category>
      <category>cplusplus</category>
      <category>layout</category>
    </item>
    <item>
      <title>Demystifying Java Applets Part 3: Failing Gracefully When Your Users Don't Have Java</title>
      <description>&lt;p&gt;&lt;a href="http://flickr.com/photos/brrtha/2099065164/"&gt;&lt;img src="http://depth-first.com/demo/20080312/wipeout.jpg" align="right"&gt;&lt;/img&gt;&lt;/a&gt;Contrary to popular misconception, Java applets are a mature technology ideally suited for building highly interactive Web content. Although this hasn't always been the case, a lot has changed since Sun's introduction of Java over a decade ago. Previous articles in this series have discussed why &lt;a href="http://depth-first.com/articles/2008/02/20/demystifying-java-applets-part-1-cross-browser-standards-compliant-pure-html-deployment-using-the-object-tag"&gt;the object tag alone can and should be used to deploy applets&lt;/a&gt; and how &lt;a href="http://depth-first.com/articles/2008/03/10/demystifying-java-applets-part-2-dry-deployment-with-the-javay-method"&gt;using the Javay deployment method&lt;/a&gt; can make life easier if you do. This article will address one of the most important questions of all when using applets: what happens if your user doesn't have Java?&lt;/p&gt;

&lt;h4&gt;Assume Your Users Won't Have Java&lt;/h4&gt;

&lt;p&gt;Java is ubiquitous, but it's not universal. Some users simply won't have a Java Virtual Machine (JVM) installed at all on their systems. Some will have one, but it will be disabled. Still others may have been browsing the Web for years, never realizing that Microsoft &lt;a href="http://java.sun.com/j2se/1.4.2/docs/guide/deployment/deployment-guide/upgrade-guide/"&gt;installed a hopelessly obsolete JVM&lt;/a&gt; on their machines without their knowledge, rendering useless a large amount of Web content.&lt;/p&gt;

&lt;p&gt;Regardless of why they might not have the JVM your applet requires, assume that a good number of your users won't and plan accordingly.&lt;/p&gt;

&lt;p&gt;But how?&lt;/p&gt;

&lt;h4&gt;The Javay Method and Deployment Failsafes&lt;/h4&gt;

&lt;p&gt;&lt;a href="http://depth-first.com/articles/2008/03/10/demystifying-java-applets-part-2-dry-deployment-with-the-javay-method"&gt;The Javay method&lt;/a&gt; for applet deployment can be broken down into three main parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Using the HTML 4 &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag - period. Neither &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt;, which is deprecated, nor &lt;tt&gt;&amp;lt;embed&amp;gt;&lt;/tt&gt;, which isn't even part of HTML, are needed any longer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using Microsoft's conditional comments to create an opening object tag that will work with its browsers, but keeping it DRY by re-using the rest of the tag.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Suppressing the ridiculous "Click to activate" message in IE 6/7 with &lt;a href="http://jactivating.sourceforge.net/en/"&gt;jActivating&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In contrast to other approaches, with the Javay method, we can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Know our applet will instantiate on all major browsers, and many niche browsers as well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Work only with standards-compliant HTML from start to finish.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stop using &lt;tt&gt;document.write&lt;/tt&gt; to create tags, a method which unless properly trapped will silently fail without any indication of what's wrong when JavaScript is disabled or if the script fails for some other reason.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But perhaps the biggest advantages of the Javay method are the ones most often overlooked:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It offers a cross-browser method to display failsafe content should Java be disabled or not installed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides a highly effective, cross-browser method for users to install Java directly from the page displaying the applet.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;How the Failsafe Works&lt;/h4&gt;

&lt;p&gt;When modern browsers such as Firefox and Internet Explorer encounter an &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag requesting a plugin they don't understand, they do two very useful things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;They render any valid HTML appearing after the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag's child &lt;tt&gt;&amp;lt;param&amp;gt;&lt;/tt&gt; elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They prompt the user to install the correct plugin to view the content - without redirecting them to another page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These two behaviors give us everything we need to gracefully fail if the Java plugin is unavailable. When the Java plugin is installed and enabled, users see the applet as planned. When the Java plugin is either not installed or disabled, users see both a placeholder of our choosing and a prompt, created by the browser itself, offering to install the missing plugin.&lt;/p&gt;

&lt;p&gt;The &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag lets us take this even further. We can specify, down to the revision level, the exact version of Java needed to run an applet. If that requirement changes, all we need to do is change the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag and users will be prompted to upgrade their JVM the next time they see our applet - if necessary.&lt;/p&gt;

&lt;h4&gt;Live Demo&lt;/h4&gt;

&lt;p&gt;Here's my company's 2D chemical structure editor, &lt;a href="http://metamolecular.com/chemwriter"&gt;ChemWriter&lt;/a&gt;, deployed with the Javay method:&lt;/p&gt;

&lt;p&gt;&lt;!--[if IE]&gt;&lt;object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"
width="480" height="350"&gt;&lt;script&gt;/*&lt;![endif]--&gt;&lt;script type="text/javascript"&gt;/**/&lt;/script&gt;
&lt;!--[if !IE]&gt;&lt;!--&gt;
&lt;object type="application/x-java-applet;version=1.4.2" width="480" height="350"&gt;
&lt;!--&lt;![endif]--&gt;
  &lt;param name="code" value="com/metamolecular/chemwriter/applet/EditorApplet.class"&gt;
  &lt;param name="archive" value="/applets/chemwriter.jar"&gt;
  &lt;param name="persistState" value="false"&gt;
  &lt;param name="licenseKey" value="4BC4-3C59-3E7D-182B-92B7-2E68"&gt;
  &lt;a href="http://metamolecular.com/java/"&gt;
    &lt;img src="http://depth-first.com/demo/20080310/chemwriter_plugin.png" style="padding: 125.0px 190.0px 125.0px 190.0px; border: 1px dashed red;"/&gt;&lt;/a&gt;
&lt;/object&gt;&lt;/p&gt;

&lt;p&gt;And here's what the failsafe code looks like when it's rendered:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://metamolecular.com/java/"&gt;
  &lt;img src="http://depth-first.com/demo/20080310/chemwriter_plugin.png" style="padding: 125.0px 190.0px 125.0px 190.0px; border: 1px dashed red;"/&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;One More Thing&lt;/h4&gt;

&lt;p&gt;We can take failsafes to yet another level, if we'd like. Let's say Joe comes to our site without the an installed Java plugin. Internet Explorer 6 informs him via a popup that Java is needed. Impatient to see the site's content, he closes the dialog. Without being redirected, Joe can see all of the site's content, except for the parts requiring Java, for which he sees a custom "Plugin Not Found" placeholder. Discovering that the site's content consists of highly-relevant information, he decides he wants to install the Java plugin after all. Clicking on placeholder image takes him to a Java installation page.&lt;/p&gt;

&lt;p&gt;Unlike other Java installation pages Joe may have seen, this one is specific to his browser, Internet Explorer 6.&lt;/p&gt;

&lt;p&gt;This approach work very well in practice. For example, my company's website, &lt;a href="http://metamolecular.com"&gt;metamolecular.com&lt;/a&gt; uses it. Try visiting the &lt;a href="http://metamolecular.com/java/"&gt;default Java installation page&lt;/a&gt;, and if your browser is included below, you'll be redirected to the browser-specific Java installation page:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://metamolecular.com/java"&gt;Default Page&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://metamolecular.com/java/firefox"&gt;Firefox Page&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://metamolecular.com/java/ie6"&gt;Internet Explorer 6 Page&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://metamolecular.com/java/ie7"&gt;Internet Explorer 7 Page&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://metamolecular.com/java/safari"&gt;Safari Page&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More information can be found in &lt;a href="http://metamolecular.com/articles/chemwriter-deployment"&gt;this article on deploying ChemWriter&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Last Thoughts&lt;/h4&gt;

&lt;p&gt;Java applets gained a deserved reputation in the late '90s for being difficult to deploy, a view that's now worth reconsidering. Using some simple techniques, Web applications can fail gracefully if Java is unavailable and then take steps to quickly get users back on track.&lt;/p&gt;

&lt;p&gt;Getting software reliably and securely installed on any client system is difficult, especially on the open Web. But the Java plugin and the Javay deployment method make it about as straightforward as it can possibly be.&lt;/p&gt;

&lt;p&gt;It's time reconsider applets.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Image Credit: &lt;a href="http://flickr.com/photos/brrtha/"&gt;brrtha&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 12 Mar 2008 23:26:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:fb9fb0dc-5102-4259-92bf-09b1cc73e740</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/03/12/demystifying-java-applets-part-3-failing-gracefully-when-your-users-dont-have-java</link>
      <category>Tools</category>
      <category>applet</category>
      <category>chemwriter</category>
      <category>deployment</category>
      <category>flashsatay</category>
      <category>jactivating</category>
      <category>java</category>
      <category>javay</category>
      <category>failsafe</category>
      <category>poka</category>
      <category>yoke</category>
    </item>
    <item>
      <title>Demystifying Java Applets Part 2: DRY Deployment with the Javay Method</title>
      <description>&lt;p&gt;&lt;a href="http://flickr.com/photos/thingsarebetterwithaparrott/2088815029/"&gt;&lt;img src="http://depth-first.com/demo/20080310/tag.jpg" align="right"&gt;&lt;/img&gt;&lt;/a&gt;Java applets are easy to deploy in a standards-compliant way across multiple browsers - you just need to know how. The &lt;a href="http://depth-first.com/articles/2008/02/20/demystifying-java-applets-part-1-cross-browser-standards-compliant-pure-html-deployment-using-the-object-tag"&gt;previous article in this series&lt;/a&gt; gave some general pointers to better applet deployment, including the use of the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag. This article will show how to make this deployment method even more concise with the &lt;strong&gt;Javay Method&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;Keeping it DRY&lt;/h4&gt;

&lt;p&gt;The code from the previous article used two completely different &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tags: one for Internet Explorer and one for all other browsers:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="comment"&gt;&amp;lt;!--[if !IE]&amp;gt; --&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;object&lt;/span&gt; &lt;span class="attribute"&gt;classid&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;java:com/metamolecular/chemwriter/applet/EditorApplet.class&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; 
              &lt;span class="attribute"&gt;type&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;application/x-java-applet&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
              &lt;span class="attribute"&gt;archive&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/path/to/applets/chemwriter.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; 
              &lt;span class="attribute"&gt;height&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;350&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;width&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;550&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;code&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;com/metamolecular/chemwriter/applet/EditorApplet.class&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="comment"&gt;&amp;lt;!-- For Konqueror --&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;archive&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/path/to/applets/chemwriter.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;persistState&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;false&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;center&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;img&lt;/span&gt; &lt;span class="attribute"&gt;src&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/path/to/images/chemwriter_logo.png&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;strong&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;ChemWriter content requires Java 1.4.2 or higher, which your browser does not appear to have.&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;strong&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;a&lt;/span&gt; &lt;span class="attribute"&gt;href&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;http://www.java.com/en/download/index.jsp&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;Get the latest Java Plug-in.&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;a&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;center&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;object&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="comment"&gt;&amp;lt;!--&amp;lt;![endif]--&amp;gt;&lt;/span&gt;
&lt;span class="comment"&gt;&amp;lt;!--[if IE]&amp;gt;
&amp;lt;object classid=&amp;quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&amp;quot; 
                codebase=&amp;quot;http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0&amp;quot;
                height=&amp;quot;350&amp;quot; width=&amp;quot;550&amp;quot; &amp;gt; 
  &amp;lt;param name=&amp;quot;code&amp;quot; value=&amp;quot;com/metamolecular/chemwriter/applet/EditorApplet.class&amp;quot; /&amp;gt;
  &amp;lt;param name=&amp;quot;archive&amp;quot; value=&amp;quot;/path/to/applets/chemwriter.jar&amp;quot; /&amp;gt;
  &amp;lt;param name=&amp;quot;persistState&amp;quot; value=&amp;quot;false&amp;quot; /&amp;gt;
  &amp;lt;center&amp;gt;
    &amp;lt;img src=&amp;quot;/path/to/images/chemwriter_logo.png&amp;quot; /&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;ChemWriter content requires Java 1.4.2 or higher, which your browser does not appear to have.&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;a href=&amp;quot;http://www.java.com/en/download/index.jsp&amp;quot;&amp;gt;Get the latest Java Plug-in.&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
  &amp;lt;/center&amp;gt;
&amp;lt;/object&amp;gt;
&amp;lt;![endif]--&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Conditional comments are used to ensure that IE sees one definition and standards-compliant browsers see another. But notice the large amount of repetition, specifically the parameters list, the failsafe code, and the closing &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag.&lt;/p&gt;

&lt;p&gt;Surely there must be a better way.&lt;/p&gt;

&lt;h4&gt;A Widespread Problem&lt;/h4&gt;

&lt;p&gt;Microsoft's idiosyncratic use of the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag doesn't just cause difficulties for Java applets: it rears its head with all plugin content. This problem is so widespread in the Flash world that its solution even has a name: &lt;a href="http://www.alistapart.com/articles/flashsatay/"&gt;Flash Satay&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the language of Drew McLellan, inventor of Flash Satay, the applet code listing above is the "twice-cooked method" - we repeat the same code twice.&lt;/p&gt;

&lt;p&gt;The twice-cooked method violates one of the most important principles in software development: &lt;a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself"&gt;Don't Repeat Yourself (DRY)&lt;/a&gt;. It's an invitation cross-browser bugs. If we forget to include the same parameter twice, or if we mistakenly use one parameter for IE and another for standards-compliant browsers, for example, we've just created a potentially nasty headache for ourselves.&lt;/p&gt;

&lt;h4&gt;Drying Up the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; Tag&lt;/h4&gt;

&lt;p&gt;We can DRY up our applet &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag by factoring out what's common: the parameters listing; the failsafe code; and the closing &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="comment"&gt;&amp;lt;!--[if IE]&amp;gt;&amp;lt;object classid=&amp;quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&amp;quot; codebase=&amp;quot;http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0&amp;quot;
width=&amp;quot;480&amp;quot; height=&amp;quot;350&amp;quot;&amp;gt;&amp;lt;script&amp;gt;/*&amp;lt;![endif]--&amp;gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;script&lt;/span&gt; &lt;span class="attribute"&gt;type&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;text/javascript&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;/**/&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;script&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="comment"&gt;&amp;lt;!--[if !IE]&amp;gt;&amp;lt;!--&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;object&lt;/span&gt; &lt;span class="attribute"&gt;type&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;application/x-java-applet;version=1.4.2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;width&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;480&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;height&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;350&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
&lt;span class="comment"&gt;&amp;lt;!--&amp;lt;![endif]--&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;code&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;com/metamolecular/chemwriter/applet/EditorApplet.class&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;archive&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/applets/chemwriter.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;persistState&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;false&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;licenseKey&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;4BC4-3C59-3E7D-182B-92B7-2E68&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;a&lt;/span&gt; &lt;span class="attribute"&gt;href&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;http://metamolecular.com/java/&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;img&lt;/span&gt; &lt;span class="attribute"&gt;src&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;http://depth-first.com/demo/20080310/chemwriter_plugin.png&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;style&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;padding: 125.0px 190.0px 125.0px 190.0px; border: 1px dashed red;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;a&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;object&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This approach was inspired by the &lt;a href="http://www.blatek.co.uk/blateksatay/"&gt;BlaTek Satay&lt;/a&gt; method, which uses the cute empty JavaScript as a way to prevent IE from showing unwanted characters. To my knowledge, it's never before been applied to applets.&lt;/p&gt;

&lt;p&gt;In the long tradition of naming these hacks after the original Satay method, I call this one "Javay."&lt;/p&gt;

&lt;p&gt;The Javay method's only repetition is in the &lt;tt&gt;width&lt;/tt&gt; and &lt;tt&gt;height&lt;/tt&gt; attributes. Even this redundancy could be eliminated, if we chose, by setting each to "100%" and enclosing the result in a &lt;tt&gt;&amp;lt;div&amp;gt;&lt;/tt&gt; tag that did specify size.&lt;/p&gt;

&lt;p&gt;The above code works in all major browsers, including Safari, Firefox, Internet Explorer 6 and 7, Opera, and Camino. If you find a browser on which the code doesn't work, I'd like to hear about it.&lt;/p&gt;

&lt;p&gt;Here's what the code produces, using my company's 2D structure editor &lt;a href="http://metamolecular.com/chemwriter"&gt;ChemWriter&lt;/a&gt; as an example:&lt;/p&gt;

&lt;p&gt;&lt;!--[if IE]&gt;&lt;object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"
width="480" height="350"&gt;&lt;script&gt;/*&lt;![endif]--&gt;&lt;script type="text/javascript"&gt;/**/&lt;/script&gt;
&lt;!--[if !IE]&gt;&lt;!--&gt;
&lt;object type="application/x-java-applet;version=1.4.2" width="480" height="350"&gt;
&lt;!--&lt;![endif]--&gt;
  &lt;param name="code" value="com/metamolecular/chemwriter/applet/EditorApplet.class"&gt;
  &lt;param name="archive" value="/applets/chemwriter.jar"&gt;
  &lt;param name="persistState" value="false"&gt;
  &lt;param name="licenseKey" value="4BC4-3C59-3E7D-182B-92B7-2E68"&gt;
  &lt;a href="http://metamolecular.com/java/"&gt;
    &lt;img src="http://depth-first.com/demo/20080310/chemwriter_plugin.png" style="padding: 125.0px 190.0px 125.0px 190.0px; border: 1px dashed red;"/&gt;
  &lt;/a&gt;
&lt;/object&gt;&lt;/p&gt;

&lt;h4&gt;Conclusions&lt;/h4&gt;

&lt;p&gt;To summarize, Java applets can be deployed in a cross-browser, standards-compliant way using the Javay Method. This method solves some of the trickier problems when deploying applets, specifically:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Uses the HTML 4 &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag, eliminating the deprecated &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; tag.&lt;/li&gt;
&lt;li&gt;Works on both IE and standards-compliant browsers in a DRY way.&lt;/li&gt;
&lt;li&gt;Suppresses the annoying "Click to activate" message in IE 6 and 7 with &lt;a href="http://jactivating.sourceforge.net/en/"&gt;jActivating&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Avoids the use of &lt;tt&gt;document.write&lt;/tt&gt; and the problems that can arise if JavaScript is disabled.&lt;/li&gt;
&lt;li&gt;When Java is either missing or not installed, provides a cross-browser failsafe (more on this next time).&lt;/li&gt;
&lt;li&gt;Leaves us with nothing but pure, standards-compliant HTML to write, debug, and maintain.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We've pretty much got everything the old &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; tag used to have - and more.&lt;/p&gt;

&lt;p&gt;But what if your users don't have Java? Tune in next time to see how to solve this problem once and for all.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Image Credit: &lt;a href="http://flickr.com/photos/thingsarebetterwithaparrott/"&gt;Things are Better with a Parrot&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 10 Mar 2008 11:13:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:87a62ef6-826c-45dc-8f37-371eb3a70e9f</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/03/10/demystifying-java-applets-part-2-dry-deployment-with-the-javay-method</link>
      <category>Tools</category>
      <category>java</category>
      <category>applet</category>
      <category>chemwriter</category>
      <category>javay</category>
      <category>flashsatay</category>
      <category>jactivating</category>
      <category>deployment</category>
    </item>
    <item>
      <title>Demystifying Java Applets, Part 1: Cross-Browser, Standards-Compliant, Pure HTML Deployment Using the Object Tag</title>
      <description>&lt;p&gt;&lt;a href="http://flickr.com/photos/oskay/437341128/"&gt;&lt;img src="http://depth-first.com/demo/20080220/components.jpg" align="right"&gt;&lt;/img&gt;&lt;/a&gt;A &lt;a href="http://today.java.net/pub/pq/89"&gt;2006 survey on java.net&lt;/a&gt; posed a simple question to developers: What's wrong with applets? By a significant margin, the number one complaint was that they are "too hard to deploy." This article, the first in a series, takes a look at the issue of Java applet deployment and in particular how using the &amp;lt;object&amp;gt; tag can radically simplify and enhance both the developer and end user experience.&lt;/p&gt;

&lt;h4&gt;Applets? You Must Be Joking!&lt;/h4&gt;

&lt;p&gt;Applets got a well-deserved bad reputation in the early days of Java. They were slow, difficult to deploy across browsers, and over-hyped. The situation has signficantly changed for the better, but the bad reputation lingers.&lt;/p&gt;

&lt;p&gt;There are many situations in which applets are inappropriate. The most important of these is when simple interactivity can be achieved through HTML or JavaScript (Ajax).&lt;/p&gt;

&lt;p&gt;But in many situations, HTML and JavaScript make a poor platform choice. As a specific example, consider &lt;a href="http://depth-first.com/articles/2007/11/27/chemwriter-chemical-structures-and-the-web"&gt;Web-based chemical structure editors&lt;/a&gt;. The high level of &lt;a href="http://depth-first.com/articles/2008/02/14/the-art-and-science-of-chemical-structure-diagrams-chemwriter-as-chemically-aware-vector-graphics-system"&gt;graphical manipulation&lt;/a&gt;, sophistication of data processing, and responsiveness required by these components, coupled by their ubiquity, means that it will be a long time indeed before Ajax (or Flash for that matter) is up to the challenge - and they may never be, given their design constraints.&lt;/p&gt;

&lt;p&gt;For a large number of specialized Web components, applets are the only platform.&lt;/p&gt;

&lt;p&gt;Regarding the "uncool factor", it's worth pointing out that not more than four years ago JavaScript was one of the most loathed, ridiculed, and ignored technologies around. Now it &lt;a href="http://www.paulgraham.com/web20.html"&gt;finally works&lt;/a&gt; - meaning it's reliable enough to be used on all modern browsers. The result is Ajax and a host of interactive Web technologies that played a major role in redefining what the Web was all about.&lt;/p&gt;

&lt;p&gt;Whether a similar renaissance happens for applets is anybody's guess, but most of the prerequisites have already been met.&lt;/p&gt;

&lt;h4&gt;Deployment with the &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; Tag&lt;/h4&gt;

&lt;p&gt;If you decide to develop Web applications with applets, a major consideration will eventually become how to deploy them. Unfortunately, a bewildering array of often contradictory advice is available on the subject - most of it outdated.&lt;/p&gt;

&lt;p&gt;Many sources recommend using the &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; tag. It's the oldest method, and will generally work on most browsers. For example, to deploy my company's structure editor applet &lt;a href="http://metamolecular.com/products/chemwriter"&gt;ChemWriter&lt;/a&gt;, the following code could be used:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;applet&lt;/span&gt; &lt;span class="attribute"&gt;code&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;com/metamolecular/chemwriter/applet/EditorApplet.class&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="attribute"&gt;archive&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/path/to/applets/chemwriter.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="attribute"&gt;width&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;600&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;height&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;300&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;persistState&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;false&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;applet&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Unfortunately, the &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; tag has some very important strikes against it. The first is that its use is &lt;a href="http://www.w3.org/TR/html401/struct/objects.html#h-13.4"&gt;now deprecated&lt;/a&gt; in HTML. In other words, whatever support browsers now have for it is living on borrowed time.&lt;/p&gt;

&lt;p&gt;The second problem with the &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; tag is an insidious bug in Internet Explorer (as if there were any other kind). Most hardware suppliers pre-install Java onto their Microsoft-based machines, which is a good thing. The bad thing is that at least one major manufacturer disables the Java console in IE 7 at the same time. Under IE 7, disabling the Java console renders all &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; tags invisible. Counterintuitive as it may seem, this is what happens. The insidious part is that perplexed users &lt;em&gt;know&lt;/em&gt; they have Java installed because they can see the plug-in, are being told by IE that it's active, can find some applets that *do* work and - well, you get the idea.&lt;/p&gt;

&lt;p&gt;The third problem with the &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; tag is that, by itself, it has no mechanism to indicate which version of Java is required. This can be a very important consideration for applets that take advantage of the major advances in functionality and performance of the Java platform in recent years.&lt;/p&gt;

&lt;h4&gt;A Better Way: Deployment with the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; Tag&lt;/h4&gt;

&lt;p&gt;All major browsers support the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag, and this is the &lt;a href="http://ww2.cs.fsu.edu/~steele/XHTML/appletObject.html"&gt;preferred method for deploying applets&lt;/a&gt;. Provided that Internet Explorer's peculiarities are accounted for, a single piece of valid HTML can render applets on all major browsers including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IE 6/7&lt;/li&gt;
&lt;li&gt;Firefox 1.5/2&lt;/li&gt;
&lt;li&gt;Safari&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a specific example using ChemWriter, the &lt;tt&gt;&amp;lt;applet&amp;gt;&lt;/tt&gt; tag above can be re-written with the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="comment"&gt;&amp;lt;!--[if !IE]&amp;gt; --&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;object&lt;/span&gt; &lt;span class="attribute"&gt;classid&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;java:com/metamolecular/chemwriter/applet/EditorApplet.class&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; 
              &lt;span class="attribute"&gt;type&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;application/x-java-applet&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
              &lt;span class="attribute"&gt;archive&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/path/to/applets/chemwriter.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; 
              &lt;span class="attribute"&gt;height&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;350&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;width&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;550&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;code&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;com/metamolecular/chemwriter/applet/EditorApplet.class&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="comment"&gt;&amp;lt;!-- For Konqueror --&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;archive&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/path/to/applets/chemwriter.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;param&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;persistState&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;false&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;center&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;img&lt;/span&gt; &lt;span class="attribute"&gt;src&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;/path/to/images/chemwriter_logo.png&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;strong&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;ChemWriter content requires Java 1.4.2 or higher, which your browser does not appear to have.&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;strong&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;a&lt;/span&gt; &lt;span class="attribute"&gt;href&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;http://www.java.com/en/download/index.jsp&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;Get the latest Java Plug-in.&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;a&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;center&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;object&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="comment"&gt;&amp;lt;!--&amp;lt;![endif]--&amp;gt;&lt;/span&gt;
&lt;span class="comment"&gt;&amp;lt;!--[if IE]&amp;gt;
&amp;lt;object classid=&amp;quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&amp;quot; 
                codebase=&amp;quot;http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0&amp;quot;
                height=&amp;quot;350&amp;quot; width=&amp;quot;550&amp;quot; &amp;gt; 
  &amp;lt;param name=&amp;quot;code&amp;quot; value=&amp;quot;com/metamolecular/chemwriter/applet/EditorApplet.class&amp;quot; /&amp;gt;
  &amp;lt;param name=&amp;quot;archive&amp;quot; value=&amp;quot;/path/to/applets/chemwriter.jar&amp;quot; /&amp;gt;
  &amp;lt;param name=&amp;quot;persistState&amp;quot; value=&amp;quot;false&amp;quot; /&amp;gt;
  &amp;lt;center&amp;gt;
    &amp;lt;img src=&amp;quot;/path/to/images/chemwriter_logo.png&amp;quot; /&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;ChemWriter content requires Java 1.4.2 or higher, which your browser does not appear to have.&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;a href=&amp;quot;http://www.java.com/en/download/index.jsp&amp;quot;&amp;gt;Get the latest Java Plug-in.&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
  &amp;lt;/center&amp;gt;
&amp;lt;/object&amp;gt;
&amp;lt;![endif]--&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Before explaining the code, here's what the verbosity buys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It works with both IE 6/7 &lt;em&gt;and&lt;/em&gt; standards-compliant browsers such as Firefox.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It avoids the use of &lt;a href="http://depth-first.com/articles/2007/11/20/write-once-run-anywhere-simplifying-java-applet-deployment"&gt;JavaScript JVM detection methods&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It prompts the user to download the correct JVM, &lt;em&gt;without immediately directing them away from the current page&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Firefox and IE users can opt to install the Java plugin without ever leaving their current page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It works in IE 7 with the Java console disabled.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;You've Got Some 'Splainin' to Do&lt;/h4&gt;

&lt;p&gt;The code above is based on documentation found on &lt;a href="http://ww2.cs.fsu.edu/~steele/XHTML/appletObject.html"&gt;this site&lt;/a&gt;, which also details the meaning of the &lt;tt&gt;codebase&lt;/tt&gt; and &lt;tt&gt;classid&lt;/tt&gt; attributes.&lt;/p&gt;

&lt;p&gt;The main idea is that Internet Explorer handles the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag in its own idiosyncratic, lovable way. Most of this difference is in the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; element itself and the &lt;tt&gt;classid&lt;/tt&gt; attribute in particular. By taking advantage of Internet Explorer's support for &lt;a href="http://msdn2.microsoft.com/en-us/library/ms537512.aspx"&gt;conditional comments&lt;/a&gt;, we can handle both IE and the rest with one chunk of HTML.&lt;/p&gt;

&lt;h4&gt;A Live Demonstration&lt;/h4&gt;

&lt;p&gt;For a live demonstration of the above technique, see the &lt;a href="http://metamolecular.com/products/chemwriter/"&gt;ChemWriter Home Page&lt;/a&gt;. If you have Java 1.4.2 or higher installed and activated in your browser, you'll see the most recent version of the ChemWriter editor applet. If not, you'll see the ChemWriter logo and a link to install Java. Firefox and IE will also display an "Install Plugin" bar at the top of the browser for in-place installation of the JVM.&lt;/p&gt;

&lt;h4&gt;Click to Activate: Working Around Eolas&lt;/h4&gt;

&lt;p&gt;A &lt;a href="http://depth-first.com/articles/2007/11/02/eolas-and-jactivating-working-around-a-workaround"&gt;recent Depth-First article&lt;/a&gt; discussed the problem that IE 6 and 7 have involving a "click to activate" (or "Eolas") message that appears with applets and all other browser plugins. To eliminate this issue, the &lt;a href="http://metamolecular.com/products/chemwriter/"&gt;ChemWriter Home Page&lt;/a&gt; uses the excellent &lt;a href="http://jactivating.sf.net/"&gt;jActivating library&lt;/a&gt;. This JavaScript library, which is included in the HTML &lt;tt&gt;&amp;lt;head&amp;gt;&lt;/tt&gt; tag, obviates the need to write the &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; tag using JavaScript. All that's left is pure, standards-compliant HTML to debug, deploy, and maintain.&lt;/p&gt;

&lt;h4&gt;Conclusions&lt;/h4&gt;

&lt;p&gt;Applet deployment, like Java itself, has come a long way in the last ten years. This article has shown one method to deploy applets into highly heterogeneous computing environments with relatively little effort.&lt;/p&gt;

&lt;p&gt;But deployment is only one aspect of interactive Web development using applets. Future articles will discuss some of the others.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Image Credit: &lt;a href="http://flickr.com/photos/oskay/"&gt;oskay&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 20 Feb 2008 09:41:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:939270fa-0bf7-4e28-8991-07c45a8a03f1</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/02/20/demystifying-java-applets-part-1-cross-browser-standards-compliant-pure-html-deployment-using-the-object-tag</link>
      <category>Tools</category>
      <category>java</category>
      <category>applet</category>
      <category>chemwriter</category>
      <category>deploy</category>
      <category>objecttag</category>
      <category>applettag</category>
      <category>jactivating</category>
      <category>eolas</category>
    </item>
  </channel>
</rss>
