Remember answering a question like this. Anyways, there are a few things to be noted. Runtime.exec() is not quite the same as system() in C as you'll see. And, to use environment variables, I dont think its a good idea to put them in the code because they can change at any moment. Instead, use System.getProperty("java.class.path") to get the $CLASSPATH at that moment. Heres a class that can compile and run another class (works well on Win2000 and JDK1.3.1_01):