I have been experimenting with a small program to set the desktop image to the current \"Astronomy Picture of the Day\". I have been using the JNA suggestion to set the wall
You can take a look and see how JAWC does it.
FTS:
Jawc stands for Just Another Wallpaper Changer or, if you prefer, JAva Wallpaper Changer. It is a Plugin-Based Wallpaper Changer and can change your desktop background picture from a > lot of different sources like your PC's folders, or Flickr, or VladStudio, just depending on > which plugins you enable.
Jawc is written using Java and it has been tested to work on Windows, Linux and Mac Os X systems.
Further to Rodrigo's answer, see these classes in particular: http://jawc-wallpaperc.svn.sourceforge.net/viewvc/jawc-wallpaperc/trunk/Jawc/src/it/jwallpaper/platform/impl/