Ever since Sun announced the inclusion of Java DB, known in the wild as Derby, in the JDK of the Java SE platform, there have been many complaints about it. A recent blog entry (funny URL by the way :) by Simon Morris caught my attention. I understand why one would complain about bloating the JDK with a database, or with the WS stack or even Rhino for that matter. Yet, the inclusion of Java DB can be a good thing for the desktop, even if it's far from being the most crucial thing Sun could do.
I am not saying that Java desktop applications are DB oriented or need a DB. I am saying it is good to learn from the other platforms. Living in our comfy SE world, we worry less about frameworks, patterns, databases and all those incredibly boring (IMHO :) stuff that half of Java developers seem to love talking and reading about (remember that there are more Swing developers than EE developers on the US market and yet, something like 99% of the Java literature focuses on EE :) That said, the EE guys came up with great stuff that we need to start using in our very own world.
What is a DB good for in a desktop application? It's quite simple actually: persistence. Take Java DB, add a JPA framework and you get something great for your and your users. Wouldn't you like all your desktop applications to retain their state from one run to another? This is something I love about virtualization software like Parallels or VMWare: you can suspend your activity, shutdown the system, come back later and get back at the exact point you left. How cool would it be if every application out there would let you snapshot your activity? Forget about undo and redo, welcome to transactional workflows! Sure you can do that kind of things without a DB but with the JPA and a good underlying framework like HIbernate you can get this easily.
Using a DB and a JPA compliant framework also makes preferences management much easier. Just persist POJOs instead of twiddling with properties files, XML files, java.util.Properties or HashMaps. A DB is also exactly what you need for some performance related issues. Mixing POJO persistence with the JPA and some soft/weak references, you can create cool caching systems for your application. This is something that can be really useful if you have a very rich UI that generates a lot of in-memory images for instance. To get started using JPA in your desktop applications, take a look at Joshua Marinacci's introduction articles.
And those are just a few examples of what you can do. Don't think of the DB as the core element of your application, think of it as an asset. Your application does not have to be a CRUD oriented piece of software to make use of a DB. It just has to be, well, an application. Adding a DB in the JDK is a good move from Sun. I think many developers are like me: when I find a tool I didn't know in my development toolbox, I want to try it and see whether it can do me any good. I hope that when people will see a database in their JDK, they will start thinking about what they could do with it instead of relying on the crude tools included in the JDK (like Properties and stuff like that.) It makes also things a bit easier when you want to try something with a database or just move to web development by adding Tomcat on top of your JDK. Why bother installing a full-blown DB environment like MySQL or PostgreSQL when you already have something ready to go?
So, am I totally happy with Java SE as it stands today? Well… read on.
Now, a message to Sun. please talk to the Java Client Group guys and ask them what should really go into the JDK! We need solid media APIs, we need data binding, we need a new, modern and cross-platform look and feel (they'll know which one I'm talking about). There are so many people out there writing Swing applications, so many people who love to write Swing applications… Help them for [something you worship here]'s sake! You've seen numerous times what Swing and Java2D were capable of, now make that easier for everyone if you really want to keep all these developers around. Forget about Flash and watch out for Microsoft's WPF or even Apple's desktop technologies and you'll see what today's developers are expecting from a desktop platform.
You proved Java successful on the servers and on the mobile phones. Now it's time to take control of the desktop. You got a large audience only waiting for your move.