Jul 042014
 

I used to code full-time for a living – these days I am a ScrumMaster. I wrote this post in an email to a friend on 16 November 2006 and always meant to blog it! At the time I had been coding in Delphi for years and was just getting into Java via an Applet.

I'm always interested in process of enlightenment – the context here is coding. It began with a bug where the date:time shown on the Java Applet About was not the build time (of the backend Delphi app) but the current date:time.

Researching it, reading the date:time from the system jar file was messy and involved signing the jar. I tried that and one of the things seemed to be that the signature would have to be renewed every 6 months, it was just an overkill solution for me. Other suggestions seemed to be to include a date:time stamp file in the distribution. So I researched reading a file, not at this point realising that by including a file in the distribution it meant wrapping it in that jar.

I realised the later from some random forum post which also mentioned Ant, so I started looking at that and ended up eventually discovering the propertyfile task where I could create this timestamp file in one fell swoop.

<propertyfile
file="${build}/datetime.inc">
<entry key="CompileDateTimeStr" type="date" value="now" pattern="d MMM yyyy HH:mm:ss"/>
</propertyfile>

The only problem with this was that the above pattern writes slashes in the time for some reason…this was a reason to look at Java's regular expression implementation which got rid of the slashes.

In the meantime it was annoyingme off that I could not see a GUI preview of the Java swing dialog I was working on. Pulling a particular dialog up was not always straight forward, there had to be a better way. After much searching and posting some kindly sole on Java ranch told me about JDemo, I started playing with that, it involved needing to reuse my Java code and after further research the only way of doing that was to introduce packages to my code.

But introducing packages stopped my applet loading and frustration ensued. I learnt that an Applet can't be started from the command line, it needs a container (browser/applet viewer). A Java debugging page lead me to turning on debugging on the console which had not been providing any useful info and that showed the Applet hanging at an image load. The image path was relative not absolute and hey presto the applet loaded and opened!

Then I opened the About screen and the build date showed perfectly, a priority 4 bug squashed and a lot learned along the path.