Build script for Sublime Text to compile & run the Java file within Sublime Text.
You can create new build script as below:

Before executing build, you need to save your Java file.
By default it’ll compile & run your Java file.
But you can perform individual task with the following commands:
1) Compile Java
2) Run Java
{
"cmd": ["javac", "-Xlint", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"cmd": ["java", "$file_base_name"],
"variants": [
{
"cmd": ["javac", "-Xlint", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"name": "Compile Java"
},
{
"cmd": ["java", "$file_base_name"],
"name": "Run Java"
}
]
}