Have you looked at marketcetera? It's free, provides adapters for several brokers, implemented in Java.
It supposed to let you automated your trades easily, I cannot comment personally though, I do not use it but I am planning to test it over the summer.