Take a look at the *.desktop file of jEdit (it's a text editor written in Java and ships in Ubuntu's universal repository). First of all: create a copy of jedit.desktop and modify all the relevant entries. Most of them are relevant.
Now the problematic entry is StartupWMClass. If you don't set up this correctly, Unity won't be able to "identify" the process/window that is launched by the executable specified by the "Exec" entry.
You can start up SQuirreL and use xprop to get the correct value. I'll help you: it's "net-sourceforge-squirrel_sql-client-Main"