<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Darwin&#039;s Theories - Java category</title>
  <link>http://theories.darwinsys.com:80/categories/java/</link>
  <description>Call it a Blog if you like -- Ian</description>
  <language>en</language>
  <copyright>Ian Darwin</copyright>
  <lastBuildDate>Wed, 08 May 2013 01:45:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>Apple and OpenJDK</title>
    <link>http://theories.darwinsys.com:80/2011/02/24/1298569020000.html</link>
    
      
        <description>
          Lest anyone doubt Apple&#039;s committment to working with Oracle on the OpenJDK project, Apple just emailed me back on a bug that I filed against the Mac implementation of Java... way back... in... 2003?!? Yup. Apple BugID #3179542 has finally been closed, a just about eight years to the day after I filed it.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Engineering believes that this issue has been resolved.&amp;nbsp; Java 7 for Mac OS X as provided by Oracle will offer the directory structure that you seek.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
I&#039;d actually moved on from OS X on my desktop many of those years ago, and had utterly forgotten sending this report, but it&#039;s good to see them finally taking Java seriously, or at least making an effort.
        </description>
      
      
    
    
    
    <category>Software Industry</category>
    
    <category>Open Source Software</category>
    
    <category>Java</category>
    
    <comments>http://theories.darwinsys.com:80/2011/02/24/1298569020000.html#comments</comments>
    <guid isPermaLink="true">http://theories.darwinsys.com:80/2011/02/24/1298569020000.html</guid>
    <pubDate>Thu, 24 Feb 2011 17:37:00 GMT</pubDate>
  </item>
  
  <item>
    <title>JavaOne without Moscone Center?</title>
    <link>http://theories.darwinsys.com:80/2010/01/27/1264611000000.html</link>
    
      
        <description>
          &lt;p&gt;
After a very long and uncomfortable silence,
Oracle, having passed the last(?) regulatory hurdle to their acquisition of Sun Microsystems, today announced that the
&lt;a href=&#039;http://java.sun.com/javaone/&#039;&gt;
JavaOne conference&lt;/a&gt; will in fact go ahead - this year.
It will be co-located, but not merged, with 
&lt;a href=&#034;http://www.oracle.com/us/openworld/&#034;&gt;Oracle 
OpenWorld&lt;/a&gt;;
this year&#039;s dates are September 19-23 in San Francisco.
That means there is still time for the refereed-paper approach that has been used in past JavaOnes.
Partly since Moscone cannot hold all the attendees who would take part in both programs, and partly to reinforce the fact that it&#039;s not merged, JavaOne will be held in three hotels near Moscone (the huge keynotes will however be held in Moscone).
I was heartened to hear Justin Kestylin of Oracle say that they want to &#034;maintain the soul of JavaOne.&#034;
We shall of course be watching to see how well they do at that.
&lt;/p&gt;
&lt;p&gt;
JavaOne will also be going on the road: the &#034;Sun Tech Days&#034; program will be replaced by regional JavaOne conferences;
the initial locations over the next year will be
China, India, Russia and Brazil.
&lt;/p&gt;
&lt;p&gt;There is an FAQ coming within the next day on Oracle Developer Network.
The following programs will be preserved:
java.net, java.sun.com, Java Community Process,
and others.
&lt;/p&gt;
&lt;p&gt;Watch 
&lt;a href=&#034;http://otn.oracle.com/&#034;&gt;otn.oracle.com&lt;/a&gt;
for the FAQ - I&#039;ll update this with the link
once it&#039;s available.
&lt;/p&gt;
        </description>
      
      
    
    
    
    <category>Software Industry</category>
    
    <category>Java</category>
    
    <comments>http://theories.darwinsys.com:80/2010/01/27/1264611000000.html#comments</comments>
    <guid isPermaLink="true">http://theories.darwinsys.com:80/2010/01/27/1264611000000.html</guid>
    <pubDate>Wed, 27 Jan 2010 16:50:00 GMT</pubDate>
  </item>
  
  <item>
    <title>OpenMoko and Android</title>
    <link>http://theories.darwinsys.com:80/2009/04/21/1240335300000.html</link>
    
      
        <description>
          A few people have asked me at various times for a comparison of the&amp;nbsp;  &lt;a href=&#034;http://www.openmoko.org/&#034;&gt;OpenMoko&lt;/a&gt; and  &lt;a href=&#034;http://developer.android.com/&#034;&gt;Android&lt;/a&gt; cell phone projects. Given that I advocate for the former, and also for  &lt;a href=&#034;http://java.com/&#034;&gt;Java&lt;/a&gt; which is (and is not) the base language of the latter, I am expected to be able to say something intelligible by way of comparison. So here goes.&lt;br /&gt;
&lt;br /&gt;
Android is a project spearheaded by Google to make an open-source phone. It uses Linux and its own Dalvik virtual machine, and applications are written in Java against the Android API and compiled down to Dalvik bytecode. Android does not expose the rest of the Linux services and does not support other programming languages. Android phones are available from a few carriers.&lt;br /&gt;
&lt;br /&gt;
Openmoko, funded by Openmoko.com, is at the other end of the spectrum: it also uses Linux, but exposes all of it to the developer. The &amp;quot;main&amp;quot; stack of phone apps has been re-written several times, using various X-based toolkits. The &amp;quot;official&amp;quot; OM2009 stack is in large part written in Python. C/C++, Java and Perl are all available. Openmoko phones are available from  &lt;a href=&#034;http://www.openmoko.com/&#034;&gt;Openmoko.com&lt;/a&gt;. However, because it is all open source:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;you can &lt;a href=&#034;http://wiki.openmoko.org/wiki/Android&#034;&gt;run Android on Openmoko hardware&lt;/a&gt;;&lt;/li&gt;
    &lt;li&gt;you could (people have) run Openmoko software on other devices, including Palm PDAs, other Linux phones, and software emulators;&lt;/li&gt;
    &lt;li&gt;you can probably run Openmoko software on Android hardware;&lt;/li&gt;
    &lt;li&gt;you can run QTopia on Openmoko hardware;&lt;/li&gt;
	&lt;li&gt;you can run one of half a dozen Linux distributions on your Openmoko hardware;&lt;/li&gt;
    &lt;li&gt;you can (eventually) run other OSes such as OpenBSD on Openmoko hardware;&lt;/li&gt;
    &lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
From one point of view, they are not enemies. Both support the open source model. But as Openmoko developers have pointed out some time back, Android sits on top of Linux, abandoning most of the open source world and reinventing its own universe. Openmoko embraces all existing open source projects and any new open source comers.
As a single example, communicating to your Openmoko phone from a desktop/laptop computer
consists merly of running the
industry-standard &lt;em&gt;ssh&lt;/em&gt; and &lt;em&gt;scp&lt;/em&gt; programs, included with every *Nix and
readily available for those other OSes that need them.
Talking to your Android phone requires finding, installing, and figuring out how to use
an ad-hoc program called &#034;adb&#034; (at least the third use of this name, after Unix&#039; Algol/Another DeBugger and
Apple&#039;s Desktop Bus).
&lt;br /&gt;
&lt;br /&gt;
From another point of view, of course, they are competing. Competing for market share (neither has made much inroads in the consumer space). Competing for developer mindshare. Android tends to get a lot more press, partly because of the &amp;quot;big G&amp;quot; lineage.&lt;br /&gt;
&lt;br /&gt;
People sometimes ask if I think Openmoko should just fold up and go on to something different, given how far ahead Android has moved? I&#039;ve never been a fan of quitting while you&#039;re behind. Imagine if Linus Torvalds had quit while Unix was ahead; his then-little school project would never have seen the light of day, and we&#039;d all be running BSD and System V. Nothing wrong with those - BSD was already on its way to becoming a full open source *Nix, as represented today by OpenBSD, FreeBSD and NetBSD - but things would be rather different in what is now the Linux community, to say the least. Or if Bill Gates had quit while IBM was ahead. Or if Steve Jobs had quit while MS-Windows was ahead. Or if the U.S. had quit the space race when the Russians launched Sputnik. You get the idea. Don&#039;t quit while you&#039;re behind, nor when you&#039;re ahead. As Nathaniel Branden once put it, &amp;quot;a beating heart is a living heart&amp;quot; - so keep on pumping!&lt;br /&gt;
&lt;br /&gt;
And, at any rate, the &amp;quot;real&amp;quot; release of Openmoko software, &lt;a href=&#034;http://wiki.openmoko.org/wiki/Om2009&#034;&gt;OM.2009&lt;/a&gt;, is almost upon us; I am running a beta of it on my Freerunner (GTA02), and it&#039;s actually usable as a cell phone. Butt-ugly compared to some of the earlier releases, but it &amp;quot;just works&amp;quot;. Formal release is expected this summer.
        </description>
      
      
    
    
    
    <category>Software Industry</category>
    
    <category>Open Source Software</category>
    
    <category>Java</category>
    
    <category>OpenBSD</category>
    
    <category>Telephony</category>
    
    <comments>http://theories.darwinsys.com:80/2009/04/21/1240335300000.html#comments</comments>
    <guid isPermaLink="true">http://theories.darwinsys.com:80/2009/04/21/1240335300000.html</guid>
    <pubDate>Tue, 21 Apr 2009 17:35:00 GMT</pubDate>
  </item>
  
  <item>
    <title>Microsoft Bites Me Again</title>
    <link>http://theories.darwinsys.com:80/2009/03/17/1237322220000.html</link>
    
      
        <description>
          I just created a Java application that is needed on several platforms, one of which, alas, is the ubituitous and ill-designed Microsoft Windows XP.&amp;nbsp; In the project there are some classes that are auxilliary to the main program. Naturally enough I created a package for these called &amp;quot;aux&amp;quot;. In Java a package name is also used as a directory name when the files are stored outside of archives, as they are during development. Hmmm. &amp;quot;aux&amp;quot;.&amp;nbsp; I know that Apple Computer long ago had a UNIX version called A/UX, but I didn&#039;t know anybody else had dibs on the name. But it seems Bill Gates was after Apple even back when MS-DOS was being cloned from CP/M-86. For it turns out that &amp;quot;aux&amp;quot; is a reserved filename, not just in MS-DOS, but even today in Windows XP (for all I know and don&#039;t care so please don&#039;t tell me, Vista too). It&#039;s because &amp;quot;aux:&amp;quot; is a device name, and the system is too scatterbrained to tell whether you mean that, or a file, if you just type &amp;quot;aux&amp;quot;. The result is that WinZip was unable to restore all the files in this package; so I had to waste about half an hour adapting to this (including copying these files again, changing their package name, changing all the files that refer to them, making sure the changes made it back to my real OS (no extra points if you can guess which one it is) and get committed into my source repo so that I don&#039;t have to put up with this &amp;quot;hideous botch&amp;quot; ever again. Until next time we meet some screw loose in the M$ universe, that is.
        </description>
      
      
    
    
    
    <category>Software Industry</category>
    
    <category>Java</category>
    
    <comments>http://theories.darwinsys.com:80/2009/03/17/1237322220000.html#comments</comments>
    <guid isPermaLink="true">http://theories.darwinsys.com:80/2009/03/17/1237322220000.html</guid>
    <pubDate>Tue, 17 Mar 2009 20:37:00 GMT</pubDate>
  </item>
  
  <item>
    <title>Using Java enums properly in Seam</title>
    <link>http://theories.darwinsys.com:80/2009/01/27/1233094920000.html</link>
    
      
        <description>
          The &lt;a href=&#034;http://www.seamframework.org/&#034;&gt;Seam&lt;/a&gt; documentation covers this now, but it&#039;s a bit short of complete examples. Most of this probably applies to other JSF/JPA deployments too (but please don&#039;t ask me how). To make the list of a given enum&#039;s values available to the view,&amp;nbsp; just add one new annotated method to a &amp;quot;Factories&amp;quot; class. &lt;br /&gt;
&lt;br /&gt;
@Name(&amp;quot;factories&amp;quot;)&lt;br /&gt;
public class Factories {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; @Factory(&amp;quot;countries&amp;quot;) &lt;br /&gt;
&amp;nbsp; &amp;nbsp; public Country[] getCountries() { &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; return Country.values(); &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&lt;br /&gt;
Because you want to display a user-friendly name in the web form, but store a short and consistent name in the database, the enum must have a &amp;quot;label&amp;quot; or &amp;quot;name&amp;quot; field and a getter method (many enums already do). For example, we&#039;ll display Canada in the drop-down but enter the ISO-3166 country code CA in the database.&lt;br /&gt;
&lt;br /&gt;
/** See ISO-3166 */&lt;br /&gt;
public enum Country { &lt;br /&gt;
&amp;nbsp;&amp;nbsp; CA(&amp;quot;Canada&amp;quot;), &lt;br /&gt;
&amp;nbsp;&amp;nbsp; US(&amp;quot;United States&amp;quot;), &lt;br /&gt;
&amp;nbsp;&amp;nbsp; AF(&amp;quot;Afghanistan&amp;quot;), &lt;br /&gt;
&amp;nbsp;&amp;nbsp; ... &lt;br /&gt;
&amp;nbsp;&amp;nbsp; ; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; private String longName; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; private Country(String longName) { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.longName = longName; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&amp;nbsp;&amp;nbsp; public String getLongName() { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return longName; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&amp;nbsp;  &amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; @Override &lt;br /&gt;
&amp;nbsp;&amp;nbsp; public String toString () { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return getLongName(); &lt;br /&gt;
&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&lt;br /&gt;
You typically want to save the string name rather than the ordinal value into the database (especially with Countries where the list order  will change in future as countries split or join!) the @Entity class must be annotated  thusly: &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; @Column(name=&amp;quot;Country&amp;quot;) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; @Enumerated(EnumType.STRING)&amp;nbsp;&amp;nbsp; // default and only other choice is  ORDINAL &lt;br /&gt;
&amp;nbsp;&amp;nbsp; public Country getCountry() { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.country; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&lt;br /&gt;
Then, to select it (display a drop-down), you&#039;d use, for example: &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;h:selectOneMenu  value=&amp;quot;#{register.personalAddress.country}&amp;quot;&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:selectItems var=&amp;quot;country&amp;quot;  value=&amp;quot;#{countries}&amp;quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label=&amp;quot;#{country.longName}&amp;quot;  noSelectionLabel=&amp;quot;-- Select --&amp;quot;/&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:convertEnum/&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/h:selectOneMenu&amp;gt; &lt;br /&gt;
&lt;br /&gt;
If you&#039;ve used another framework than Seam, there&#039;s a bit of Seam&#039;s beauty: the Seam convertEnum tag fixes the &#039;orrible mess of having your data classes be required to know about UIComponent (can nobody on the JSF standards committee spell &amp;quot;tier violation&amp;quot;?).&lt;br /&gt;
&lt;br /&gt;
To display the current value in a view-only page,&amp;nbsp; you just need, for example, &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;h:outputText id=&amp;quot;country&amp;quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value=&amp;quot;#{person.personalAddress.country.longName}&amp;quot;/ &amp;gt; &lt;br /&gt;
&lt;br /&gt;
The data must be basically spotless for the enum converter to work, so - if you didn&#039;t have enumerating check constraints on the database from day one - you may e.g., have to &amp;quot;sanitize&amp;quot; the data a little to ensure  there are no non-null but blank&lt;strong class=&#034;moz-txt-star&#034;&gt;&lt;span class=&#034;moz-txt-tag&#034;&gt;&lt;/span&gt;&lt;/strong&gt; values in the database, or convert any lower-case values to upper case to match the enum constants. If not you&#039;ll get strange message like the famous &amp;quot;can&#039;t find resultList&amp;quot; - always check the JBoss console log for a stack trace!&lt;br /&gt;
&lt;br /&gt;
These can be cleaned with SQL like this, using whatever tool you use to feed raw SQL into whatever database you&#039;re using:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; update address set country = &#039;CA&#039; where country = &#039;&#039; &lt;br /&gt;
Or you could set these values to NULL.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; update address set country = upper(country) &lt;br /&gt;
&lt;br /&gt;
To check the values, you can use SQL similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct(country) from address&lt;br /&gt;
&lt;br /&gt;
Then it all works nicely, as it should, without any need for EntityConverter or for mixing UIComponents into your data layer. Seam rocks!
        </description>
      
      
    
    
    
    <category>Java</category>
    
    <category>Web</category>
    
    <comments>http://theories.darwinsys.com:80/2009/01/27/1233094920000.html#comments</comments>
    <guid isPermaLink="true">http://theories.darwinsys.com:80/2009/01/27/1233094920000.html</guid>
    <pubDate>Tue, 27 Jan 2009 22:22:00 GMT</pubDate>
  </item>
  
  </channel>
</rss>
