Creating a build file/system is intended for this purpose. The documentation is not very expansive, and it helps to examine existing 'sublime-build' files. There seems to be two called Ant. and JavaC.sublime-build in the Packages\Java folder.
Essentially, you create a file with extension 'sublime-build' and store it in your Packages\User folder. It is possible to store it in \Java (or anywhere within \Packages) but \User is preferred. Then a new Tools/ Build System menu option will be available for you.
But I would assume that someone, somewhere , has already gone through this process and may advise/assist you for Java.