<?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 applet</title>
    <link>http://depth-first.com/articles/tag/applet</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>Solve Web Application Scaling Problems With Signed Applets</title>
      <description>&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080425/signature.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 25 Apr 2008 13:12:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:8bb7ed9e-2e45-4afc-ab7c-1d0f09987ae6</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/04/25/solve-web-application-scaling-problems-with-signed-applets</link>
      <category>Tools</category>
      <category>applet</category>
      <category>signature</category>
      <category>signedapplet</category>
      <category>designingtheobvious</category>
      <category>userinterface</category>
      <category>webdesign</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>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>
    <item>
      <title>Hacking JSpecView: Enhancing the User Interface</title>
      <description>&lt;p&gt;&lt;center&gt;&lt;applet code="jspecview/applet/JSVApplet.class" name= "jsv" mayscript="true" archive="http://depth-first.com/demo/20080201/jspecview.jar" width="490" height="350"&gt;&lt;param name="script" value="load http://depth-first.com/demo/20080128/demo/demo1/netanilineH.jdx; reverseplot true; gridon false; plotcolor 150,100,200;" /&gt;&lt;/applet&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://depth-first.com/articles/2008/01/28/hacking-jspecview-creating-an-html-test-harness"&gt;last installment&lt;/a&gt; of this series showed how to set up an HTML testing harness for JSpecView. With the preliminaries taken care of, this installment will show how to enhance the user interface.&lt;/p&gt;

&lt;h4&gt;The Goal&lt;/h4&gt;

&lt;p&gt;The live applet shown above illustrates the changes that were made. As you move your mouse cursor into the spectrum area, you'll see a vertical red line appear and track the movements of the mouse. As you presss the mouse key to begin a selection, a grey rectangle will show you exactly where the selection area will be.&lt;/p&gt;

&lt;p&gt;If you can't view the applet, be sure you system has &lt;a href="http://www.java.com/en/download/index.jsp"&gt;JDK 1.5 or higher&lt;/a&gt; installed, and that you've enabled applets for your browser.&lt;/p&gt;

&lt;p&gt;Clearly, these modifications need more work. For example, you can extend the selection box outside the boundary of the spectrum area. And green might be a better color for the cursor. Then again, maybe the cursor should use an alpha channel. But I digress.&lt;/p&gt;

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

&lt;p&gt;Being a &lt;a href="http://depth-first.com/articles/2008/01/11/my-favorite-eclipse-shortcut-quick-fix"&gt;longtime Eclipse user&lt;/a&gt;, I prefer this tool for my Java development. So far, only the use of Ant has been described. Fortunately, Eclipse offers an elegant way to import an existing Ant project. File-&gt;New gives a dialog like the one shown below:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080201/new_project.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Selecting "Java Project from Existing Ant Buildfile" gives this dialog:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080201/create_project.png"&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Filling in the fields as shown should give a fully-functional Eclipse project.&lt;/p&gt;

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

&lt;p&gt;If you check the HTML source for this page, you'll notice that the &lt;tt&gt;applet&lt;/tt&gt; tag is used to display the applet. Yet on Internet Explorer, there is no "click to activate" message. The reason is that Depth-First is using the excellent JavaScript library &lt;a href="http://depth-first.com/articles/2007/11/02/eolas-and-jactivating-working-around-a-workaround"&gt;JActivating&lt;/a&gt;, which re-writes the &lt;tt&gt;applet&lt;/tt&gt; tag so that it isn't detected by the Eolas workaround. This lets us stick with plain HTML, rather than using &lt;tt&gt;document.write&lt;/tt&gt; to specify the applet.&lt;/p&gt;

&lt;h4&gt;Changing the Source Code&lt;/h4&gt;

&lt;p&gt;Too many changes were made to detail individually. In general, they related to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Removing non-applet classes such as those involved with the desktop application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Removing code flagged by Eclipse as unused.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Editing the &lt;tt&gt;jspecview.common.JSVPanel&lt;/tt&gt; source to add the UI modifications. The &lt;tt&gt;drawGraph&lt;/tt&gt;, &lt;tt&gt;drawCursor&lt;/tt&gt;, and &lt;tt&gt;drawZoomBox&lt;/tt&gt; methods contained most of the changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The complete Eclipse project should be &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=161398&amp;amp;package_id=260592"&gt;available from SourceForge&lt;/a&gt; shortly.&lt;/p&gt;

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

&lt;p&gt;Given the right tools, modifying JSpecView is not that difficult. We've gone from raw souce code to a complete Eclipse project, and even added some functionality in the process.&lt;/p&gt;

&lt;p&gt;Where would you like to take JSpecView?&lt;/p&gt;</description>
      <pubDate>Fri, 01 Feb 2008 11:25:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:29a83e80-30b1-4da8-b4a1-be5958312bca</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/02/01/hacking-jspecview-enhancing-the-user-interface</link>
      <category>Tools</category>
      <category>jspecview</category>
      <category>applet</category>
      <category>eclipse</category>
      <category>ant</category>
      <category>xydata</category>
    </item>
    <item>
      <title>Hacking JSpecView: Creating an HTML Test Harness</title>
      <description>&lt;p&gt;&lt;a href="http://jspecview.sourceforge.net/"&gt;&lt;img src="http://depth-first.com/demo/20080123/jspecview.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;The &lt;a href="http://depth-first.com/articles/2008/01/23/hacking-jspecview-getting-organized-with-ant"&gt;previous article in this series&lt;/a&gt; discussed the construction of an Ant build environment for &lt;a href="http://jspecview.sourceforge.net/"&gt;JSpecView&lt;/a&gt;. This article will show how to use Ant to build an HTML harness to test the resulting Applet and jarfile.&lt;/p&gt;

&lt;h4&gt;Availability of Source Code&lt;/h4&gt;

&lt;p&gt;Robert Lancashire, the lead JSpecView developer, has kindly agreed to host the complete source code for this series of tutorials on the &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=161398&amp;amp;package_id=260592"&gt;JSpecView SourceForge project page&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Overview&lt;/h4&gt;

&lt;p&gt;Our goal for this session is to create an Ant task that will assemble a directory of HTML pages for testing the JSpecView applet. To do this, we'll add a new &lt;tt&gt;demo&lt;/tt&gt; task and some supporting files.&lt;/p&gt;

&lt;h4&gt;Editing the build.xml File&lt;/h4&gt;

&lt;p&gt;The main change we'll make is to add the &lt;tt&gt;demo&lt;/tt&gt; task itself:&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;target&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;demo&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;depends&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;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;mkdir&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${demo}&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;copy&lt;/span&gt; &lt;span class="attribute"&gt;todir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${demo}&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;fileset&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${resources-html}&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;copy&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;copy&lt;/span&gt; &lt;span class="attribute"&gt;file&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${build-lib}/${unix-name}-${version}.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;tofile&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${demo}/lib/${unix-name}.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;target&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 task creates a &lt;strong&gt;demo&lt;/strong&gt; directory and copies into it the contents of a new &lt;strong&gt;resources/html&lt;/strong&gt; directory, along with the jarfile built with the &lt;tt&gt;jar&lt;/tt&gt; task.&lt;/p&gt;

&lt;p&gt;Other changes to the &lt;strong&gt;build.xml&lt;/strong&gt; file are necessary. In the interest of brevity, they have been omitted. Those interested should &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=161398&amp;package_id=260592"&gt;download the source package&lt;/a&gt; to be available shortly.&lt;/p&gt;

&lt;h4&gt;Creating the &lt;strong&gt;resources&lt;/strong&gt; Directory&lt;/h4&gt;

&lt;p&gt;Think of the &lt;strong&gt;resources&lt;/strong&gt; directory as a place to hold non-Java files that will get used by our Ant tasks. Our first addition to this directory will be a directory called &lt;/strong&gt;html&lt;/strong&gt;. Here, we'll create a new directory called &lt;strong&gt;demo1&lt;/strong&gt;. It will contain an HTML document with an embedded JSpecView applet (&lt;strong&gt;index.html&lt;/strong&gt;), along with a JCAMP-DX file (&lt;strong&gt;netanilineH.jdx&lt;/strong&gt;) and the excellent &lt;a href="http://depth-first.com/articles/2007/11/02/eolas-and-jactivating-working-around-a-workaround"&gt;JActivating&lt;/a&gt; JavaScript tool.&lt;/p&gt;

&lt;h4&gt;Using the &lt;tt&gt;demo&lt;/tt&gt; Task&lt;/h4&gt;

&lt;p&gt;We can run our new &lt;tt&gt;demo&lt;/tt&gt; task just like the others:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;tt&gt;
$ ant demo
Buildfile: build.xml

init:
    [mkdir] Created dir: /home/rich/devel/proj/jspecview/build
    [mkdir] Created dir: /home/rich/devel/proj/jspecview/build/classes
    [mkdir] Created dir: /home/rich/devel/proj/jspecview/build/lib

compile:
    [javac] Compiling 48 source files to /home/rich/devel/proj/jspecview/build/classes

jar:
      [jar] Building jar: /home/rich/devel/proj/jspecview/build/lib/jspecview-20080128.jar

demo:
    [mkdir] Created dir: /home/rich/devel/proj/jspecview/demo
     [copy] Copying 3 files to /home/rich/devel/proj/jspecview/demo
     [copy] Copying 1 file to /home/rich/devel/proj/jspecview/demo/lib

BUILD SUCCESSFUL
Total time: 3 seconds
&lt;/tt&gt;
&lt;/div&gt;

&lt;p&gt;If all went well, you should see a new &lt;strong&gt;demo&lt;/strong&gt; directory with the following structure:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080128/screen.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;h4&gt;Viewing the Result&lt;/h4&gt;

&lt;p&gt;You can view the result online &lt;a href="http://depth-first.com/demo/20080128/demo/demo1/index.html"&gt;here&lt;/a&gt;. The applet loads and displays the JCAMP-DX file &lt;a href="http://depth-first.com/demo/20080128/demo/demo1/netanilineH.jdx"&gt;&lt;strong&gt;netanilineH.jdx&lt;/strong&gt;&lt;/a&gt;. Notice that the spectrum is interactive; zoom and display properties can be set by right-clicking in the applet Window.&lt;/p&gt;

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

&lt;p&gt;This tutorial has show how to build a simple HTML test harness for JSpecView. With this important step complete, we can begin to customize JSpecView itself. Future tutorials will show how.&lt;/p&gt;</description>
      <pubDate>Mon, 28 Jan 2008 10:37:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:7918de44-3bdf-462d-8167-d13d1c2104fe</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/01/28/hacking-jspecview-creating-an-html-test-harness</link>
      <category>Tools</category>
      <category>java</category>
      <category>applet</category>
      <category>jspecview</category>
      <category>ant</category>
      <category>xydata</category>
    </item>
    <item>
      <title>Hacking JSpecView: Getting Organized with Ant</title>
      <description>&lt;p&gt;&lt;a href="http://jspecview.sourceforge.net/"&gt;&lt;img src="http://depth-first.com/demo/20080123/jspecview.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;&lt;a href="http://jspecview.sourceforge.net/"&gt;JSpecView&lt;/a&gt; is a general-purpose X-Y data viewer suitable for Web applications. The &lt;a href="http://depth-first.com/articles/2008/01/22/an-introduction-to-jspecview"&gt;previous article in this series&lt;/a&gt; introduced JSpecView and discussed the importance of this kind of software in building rich, chemically-aware Web applications. This article will illustrate one way to set up the JSpecView build environment to easily enable extensions and modifications to be outlined in articles that will follow.&lt;/p&gt;

&lt;h4&gt;Prerequisites&lt;/h4&gt;

&lt;p&gt;This tutorial will use &lt;a href="http://ant.apache.org/"&gt;Apache Ant&lt;/a&gt;. For those unfamiliar with it, Ant is a platform-independent build tool like &lt;a href="http://www.gnu.org/software/make/"&gt;make&lt;/a&gt;. It automates the drudgery of compiling software and building its accessories such as documentation, jar files, and so on. Although far from perfect, Ant is the most widely-used Java build tool.&lt;/p&gt;

&lt;h4&gt;Configure Your Build Directory&lt;/h4&gt;

&lt;p&gt;Download and unpack &lt;a href="http://downloads.sourceforge.net/jspecview/JSVSsrc_2008Jan13.zip?modtime=1200256938&amp;amp;big_mirror=0"&gt;the most recent version of the JSpecView source distribution&lt;/a&gt; ("2008Jan13" as of this writing) into a directory of your choice. When finished, you should end up with a directory structure like this:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080123/dirs_initial.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Now, re-arrange the files and directories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a new directory called &lt;tt&gt;src&lt;/tt&gt; to hold source files and &lt;tt&gt;lib&lt;/tt&gt; to hold external libraries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Move &lt;tt&gt;jspecview&lt;/tt&gt;, &lt;tt&gt;mdidesktop&lt;/tt&gt;, and &lt;tt&gt;test&lt;/tt&gt; into the new &lt;tt&gt;src&lt;/tt&gt; directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Delete &lt;tt&gt;META-INF&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add an empty file called &lt;tt&gt;build.xml&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When finished, your new directory structure should look like this:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080123/dirs_final.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;h4&gt;Adding External Libraries&lt;/h4&gt;

&lt;p&gt;Compiling JSpecView in its current form requires two external libraries - let's add them now.&lt;/p&gt;

&lt;p&gt;The first library is the LiveConnect JavaScript library named &lt;strong&gt;plugin.jar&lt;/strong&gt;. It can be found in your Java Developer Kit. It's typically located under the &lt;strong&gt;jre/lib&lt;/strong&gt; directory. Copy this file into your JSpecView &lt;strong&gt;lib&lt;/strong&gt; directory.&lt;/p&gt;

&lt;p&gt;The second library we'll need is &lt;a href="http://velocity.apache.org/"&gt;Velocity&lt;/a&gt;. Copy the &lt;a href="http://apache.mirrors.redwire.net/velocity/engine/1.5/velocity-1.5.tar.gz"&gt;Velocity-1.5 jarfile&lt;/a&gt; into your JSpecView &lt;strong&gt;lib&lt;/strong&gt; directory.&lt;/p&gt;

&lt;h4&gt;Create build.xml&lt;/h4&gt;

&lt;p&gt;All that remains is to create an Ant &lt;strong&gt;build.xml&lt;/strong&gt; file. There are many ways to do this; the file presented below is but one of them:&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;xml&lt;/span&gt; &lt;span class="attribute"&gt;version&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1.0&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;project&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;JSpecView&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;default&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;compile&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;basedir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;.&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;description&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    A JCamp-DX Viewer
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;description&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;property&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;full-name&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;JSpecView&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;property&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;short-name&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;JSpecView&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;property&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;unix-name&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;jspecview&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;property&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;version&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;20080113&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;property&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;img&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;icons&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;property&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;src&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;src&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;property&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;lib&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;lib&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;property&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;build&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;build&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;property&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;build-classes&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;build/classes&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;property&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;build-lib&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;build/lib&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;property&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;doc&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;doc&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;property&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;dist&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;dist&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;property&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;bin-dist&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${dist}/bin&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;property&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;src-dist&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;location&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${dist}/src&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;target&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;compile&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;depends&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;init&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;description&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;compile the source&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;javac&lt;/span&gt; &lt;span class="attribute"&gt;srcdir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${src}&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;destdir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${build-classes}&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;debug&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;on&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;source&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1.5&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;target&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1.5&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;classpath&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;fileset&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${lib}&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;include&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;**/*.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;fileset&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;classpath&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;javac&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;target&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;target&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;jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;depends&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;compile&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;jar&lt;/span&gt; &lt;span class="attribute"&gt;jarfile&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${build-lib}/${unix-name}-${version}.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;basedir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${build-classes}&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;jar&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;target&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;target&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;init&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;mkdir&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${build}&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;mkdir&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${build-classes}&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;mkdir&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${build-lib}&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;target&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;target&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;doc&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;depends&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;compile&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;description&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;create the full api documentation&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;javadoc&lt;/span&gt; &lt;span class="attribute"&gt;sourcepath&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${src}&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;packagenames&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;*&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;destdir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${doc}&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;windowtitle&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${short-name} API&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;doctitle&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;${full-name} v${version}&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;doctitle&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;header&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;${full-name} v${version}&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;header&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;classpath&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;fileset&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${lib}&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;include&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;**/*.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;fileset&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;classpath&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;javadoc&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;target&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;target&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;clean&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;description&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;remove dist, doc, and build directories&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;delete&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${build}&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;delete&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${dist}&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;delete&lt;/span&gt; &lt;span class="attribute"&gt;dir&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;${doc}&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;target&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;project&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;The purpose of this file is to create five general-purpose scripts: &lt;tt&gt;compile&lt;/tt&gt;, &lt;tt&gt;jar&lt;/tt&gt;, &lt;tt&gt;init&lt;/tt&gt;, &lt;tt&gt;doc&lt;/tt&gt;, and &lt;tt&gt;clean&lt;/tt&gt;.&lt;/p&gt;

&lt;h4&gt;Compiling the Jarfile and Documentation&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;build.xml&lt;/strong&gt; file can be tested by using it to compile the JSpecView source:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ ant
Buildfile: build.xml

init:
    [mkdir] Created dir: /home/rich/devel/proj/jspecview/build
    [mkdir] Created dir: /home/rich/devel/proj/jspecview/build/classes
    [mkdir] Created dir: /home/rich/devel/proj/jspecview/build/lib

compile:
    [javac] Compiling 48 source files to /home/rich/devel/proj/jspecview/build/classes

BUILD SUCCESSFUL
Total time: 3 seconds
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;If you don't get this result, make sure your libraries are installed in the &lt;strong&gt;lib&lt;/strong&gt; directory and that you've moved all Java sourcecode directories into the &lt;strong&gt;src&lt;/strong&gt; directory.&lt;/p&gt;

&lt;p&gt;We can build a JSpecView jarfile just as easily:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ ant jar
Buildfile: build.xml

init:

compile:

jar:
      [jar] Building jar: /home/rich/devel/proj/jspecview/build/lib/jspecview-20080113.jar

BUILD SUCCESSFUL
Total time: 1 second
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;As you can see from the output, the jarfile has been placed into the &lt;strong&gt;build/lib&lt;/strong&gt; directory.&lt;/p&gt;

&lt;p&gt;We can also create JavaDoc documentation:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ ant doc
Buildfile: build.xml

init:

compile:

doc:
  [javadoc] Generating Javadoc
  [javadoc] Javadoc execution
  [javadoc] Creating destination directory: "/home/rich/devel/proj/jspecview/doc/"
  [javadoc] Loading source files for package jspecview.applet...
  [javadoc] Loading source files for package jspecview.application...
  [javadoc] Loading source files for package jspecview.common...
  [javadoc] Loading source files for package jspecview.exception...
  [javadoc] Loading source files for package jspecview.util...
  [javadoc] Loading source files for package jspecview.xml...
  [javadoc] Loading source files for package mdidesktop...
  [javadoc] Loading source files for package test...
  [javadoc] Constructing Javadoc information...
  [javadoc] /home/rich/devel/proj/jspecview/src/jspecview/util/DisplaySchemesProcessor.java:31: package org.apache.xerces.parsers does not exist
  [javadoc] import org.apache.xerces.parsers.DOMParser;
  [javadoc]                                 ^
  [javadoc] Standard Doclet version 1.6.0_01
  [javadoc] Building tree for all the packages and classes...
  [javadoc] Building index for all the packages and classes...
  [javadoc] Building index for all classes...
  [javadoc] Generating /home/rich/devel/proj/jspecview/doc/stylesheet.css...
  [javadoc] 1 warning

BUILD SUCCESSFUL
Total time: 10 seconds
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The result is placed into a new &lt;strong&gt;doc&lt;/strong&gt; directory. As you can see from the output above, there was a problem finding the Xerces &lt;strong&gt;DOMParser&lt;/strong&gt;, a library we may need to include in the &lt;strong&gt;lib&lt;/strong&gt; directory for future iterations.&lt;/p&gt;

&lt;p&gt;To clean up the directories our script created, we simply use:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ ant clean
Buildfile: build.xml

clean:
   [delete] Deleting directory /home/rich/devel/proj/jspecview/build
   [delete] Deleting directory /home/rich/devel/proj/jspecview/doc

BUILD SUCCESSFUL
Total time: 0 seconds
&lt;/pre&gt;
&lt;/div&gt;

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

&lt;p&gt;With a build environment configured and working, we can move on to building a test harness and making modifications. But that's a story for another time.&lt;/p&gt;</description>
      <pubDate>Wed, 23 Jan 2008 10:28:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f76da4bd-28ea-45d4-ab71-5da5a850b152</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/01/23/hacking-jspecview-getting-organized-with-ant</link>
      <category>Tools</category>
      <category>jspecview</category>
      <category>java</category>
      <category>applet</category>
      <category>xydata</category>
      <category>ant</category>
    </item>
  </channel>
</rss>
