I was going to answer you giving a piece of Makefile, but it would not be generic enough. Whenever you want to compile a more complex program (let's say 2 files), you need to compile the second as well. It might be in a package, in which case what you're asking does not work any longer. Same thing if you have to handle libraries.
For all these reasons, I strongly advise you to choose a building utility of your choice, make, scons, ant, and let's mention it maven. I find the later way to complex for small projects. But ant is my best candidate for java programs. In the end, you can just ant run which will run your program and recompile it if needed. Have a look on the hello world tutorial with ant.
java Program.javaopenjdk.java.net/jeps/330