You are asking quite a few questions in one, and need to provide more context to your problem. To begin with, look at System.exec() and Lesson: Basic I/O (The Java™ Tutorials > Essential Classes).