Skip to main content

Violently Happy

Posted by editor on July 31, 2006 at 8:06 AM PDT


Don't you love when really hard code finally starts working?

So, I had some coding time this weekend for a client, and I finally got one of the major nightmares of my coding life to start coming together. Don't you love when you rethink some really haggard code-base, make sense of it, and finally get it bullet-proofed?

If you happened to hear a mini-talk I did from JavaOne, in my guise not as editor but as owner of the Lloyd project, you'll know that I've been struggling for months with getting an AWT component to preview video capture with QuickTime for Java, which eliminated its own video capture preview component in a major re-org of their code a few years ago. In the mini-talk, I was careful to end the demo after 20 seconds, because I knew it would crash after 30. And that's only because I was on a PowerPC Mac laptop - on an Intel Mac, the same code crashed instantly. And I didn't have a Windows box to even try it on XP.

Anyways, working on similar stuff for a client, I realized that a lot of my problems came from interacting with the AWT thread, and that similar code, even samples from Apple, tended to crash if called from AWT or if the AWT event-dispatch thread was even present when the capture stuff started up (this is the kind of weirdness that pops up when you take demos that launch from main() and put them in a GUI, where the code will typically be called in response to a GUI event like a button-click or menu item, and thus be on the AWT-Event-Dispatch thread). So, I figured, I'm going to just bring all my stuff up before the AWT, and lazy-instantiate any AWT pieces I need, like the preview component. In other words, I moved from on-demand creation of the capture stuff to more of a service model, which required a whole lot of rethinking.

Suffice to say that it finally, finally works, and is fairly resistant to various forms of abuse I throw at it: changing the camera's settings, switching input devices, switching the output file or not saving to a file at all, etc. This is a huge relief, given the crash-tacular history of my work with QTJ capture. It reminds me of something Mason Glaves said in the description of his blog A tale of two GUIs, in which he described web and desktop development as, respectively: "On the one side a happy village, with crops of green test lights in neat little rows, on the other a dark jungle where code roamed free and wild, and any step you took could be your last." The idea that a crash is always lurking around the next breakpoint is disturbingly typical of what I've found over the years in desktop development, although I suppose it's not truly exclusive to the desktop: surely I'm not the only one to see someone else's web app barf up a stack trace to the browser?

Anyways, there's more work to do. My stuff deadlocks on Windows XP due to what seems to be a remarkable difference in Java threading on the two platforms (the callbacks I get when the camera has new data come from completely different threads on Mac versus Windows). Hopefully, I'll be able to take this experience and finally write a nice new video preview service class for Lloyd sometime soon, then maybe a blog or an article on the specific hazards of this particular pursuit and how to avoid them.


In Java Today,
the eighty-eighth issue of the JavaTools Community Newsletter is online, featuring tool news from around the web, links to all the projects that joined the tools community in the last week, and a "tool tip" on how to display PDF documents in Java.

The Swilet project has graduated fom the incubator to a Java Enterprise project. Swilet is a Java EE web presentation layer framework. Swilet can help programmers easily create a web application that has Ajax features, without knowledge of Ajax and JavaScript. Swilet can transform a java swing application to a web application. This allows desktop programmers to write swing programs using tools that they are expert in, and with the swilet framework, use the swing application as a web application.

Eclipse's Business Intelligence and Reporting Tools (BIRT) project offers
remarkable tools for creating and deploying report designs. It's the
deployment step that trips a lot of people up, according to author Jason
Weathersby: "Some of the most common questions in the BIRT News Group are
about deploying BIRT. The reason for this is not the complexity of
deploying, but the many deployment options." In the article Deploying
BIRT
, he looks at how to share your reports with BIRT's own viewer
servlet, incorporating it into your own servlet, and using it in a Rich
Client Platform (RCP) desktop application.


David Herron wonders about the practicalities of open-sourcing Java, specifically what Useful quality metrics to publish?, in today's Weblogs.
"'We' are having planning and discussion about how to handle Sun's Java implementation as open source. I've seen several articles and blog postings from the folk directly involved in the discussions, and it's all very interesting. What I'm most puzzling over is, what should the quality team do or publish etc in this environment?"

John O'Conner finds the scripting API changed in
Writing about work in progress sometimes hurts:
"The JSR 223 spec changes...and suddenly my code is broken."

In Embed Scripts in a desktop application, Rémi Forax offers "yet another blog entry on scripting and Java desktop application, in which the reader sees how it's easy to embed scripts in a desktop application with mustang."


This week's Spotlight is on
the Ajax4jsf project, which leverages Java Server Faces and adds the Ajax functionality for you. "The framework is implemented using a component library that adds Ajax capability to your existing pages without needing to write any JavaScript code or needing to replace existing components with new Ajax widgets. Ajax4jsf enables page-wide Ajax support instead of the traditional component-wide support." You can use it to add Ajax to existing JSF applications, write components with Ajax support, and more.


In today's Forums,
rasto1968 discovers an unpleasant surprise:
swingx and webstart requires swingx jar to be signed
"I've just created a webstart app using swingx and have found that I get a security exception. The reason appears to be the find key discovery code in JXTable (initActionsAndBindings), it looks like it uses some sort of reflection that requires security priviledges. Commenting out the find key code allows me to create an unsigned webstart app. Any thoughts on this?"

Don Casteel is looking for some help moving to SunGrid in
SunGrid Cool Apps contest - 3D Fractal Raytracer - Help Wanted
First of all the SunGrid Cool Apps contest is offering a $15,000 grand prize. ($50,000 total prize money) Some of you may be aware of the work I've been doing on trying to develop a method of generating and raytracing volumetric Apophysis-like 3D fractals. Parallel to developing the raytracer, I've also been trying to utilize the computing power of Sun's N1 grid engine to create higher resolution and quality images and someday animations. The N1 grid engine is very constrained and complex and I have not made much progress getting it to work. My application is written in 100% pure Java3D, and I'd like to keep it that way. I've been using the NetBeans computeserver plugin for the grid side of things If you're interested in becoming a part of this project, (and a part of any prize money), please send me a private email with how you think you can help.


In today's java.net
News Headlines
:

Registered users can submit news items for the href="http://today.java.net/today/news/">java.net News Page using our
news submission
form
. All submissions go through an editorial review before being
posted to the site. You can also subscribe to the href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net News RSS
feed.


Current and upcoming Java
Events
:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e">events submission form.
All submissions go through an editorial review before being posted to the
site.


Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.

Don't you love when really hard code finally starts working?