Open your Sublime
Choose the Tools->Build System->New Build System
Add below code to the new file
This can tell the sublime to run the commands
{"cmd": ["javac -cp /Users/yourusername/algs4/stdlib.jar:/Users/yourusername/algs4/algs4.jar:. \"$file\"&& java -cp java -cp /Users/yourusername/algs4/stdlib.jar:/Users/yourusername/algs4/algs4.jar:. \"$file_base_name\""],"shell":true,"file_regex": "^(...*?):([0-9]*):?([0-9]*)","selector": "source.java"}
Hope this can help those who are following the Algorithm Course from Princeton University