Smarter Bash Tab Completion
Solution 1:
*nix packages such as bash_completion
can be installed with 3rd party package managers. I suggest Homebrew, but Fink and MacPorts also provide the bash_completion
package. If it doesn't auto-handle the Java situation you describe, post back or read the man page.
Solution 2:
I would suggest you set your default shell to zsh instead of bash. It comes bundled with Mac OS X and it's fully compatible with bash, but adds some nice features including much smarter tab completion.
Try it with chsh /bin/zsh
There's also a great framework for managing your zsh environment called oh-my-zsh. It's a great starting point for some powerful customization.