First of all, this is not the correct place to post this thread. You should have created a separate thread for this on "New to Java" forum. In that way, you will also have more chance to get an answer.
I guess the best way to invoce java compiler is to use "Java Compiler API" nowadays. But i did not use it..
The Java Compiler API
And if you still think that you should invoke java/java externally, then you can use Process class to execute javac/java and listen output stream of that process. Here are some examples:
Execute an external program - Real's Java How-to