This is important both pedagogically and for real world experience. How often do you sit down and write entire apps from scratch? Surely extending, enhancing, incorporating and fixing(!) existing code are all essential skills to be learnt by any coder.

Robocode (robocode.alphaworks.ibm.com) where java classes compete battlebots-style has the right idea. Unfortunately the current implementation encourages many bad habits and introduces too many concepts tangential to basic programming skills.

Something simpler like Logo in Java would let students learn basic concepts while making pretty pictures - far more stimulating feedback than standard out provides.

Utilizing XP principles you can create self-marking activities with JUnit. The students must make each test pass in sequence giving immediate feedback and breaking tasks up into manageable chunks.