How to make a build tool for compile and run a java file for my application?

Hey i need to create a application that can compile and run a java file by clicking one button(This is for my knowledge only).How can i do this. Highly appreciate your help

Apply application plugin and execute run task via gradle gui.

For more detail information is available at