I come from an Eclipse background, but I love Vim as a text editor. I\'m currently experimenting with Vim as a Java IDE. Currently I do this to compile:
! javac
If you run linux(use bash), here is my setup: to compile and run the class with your main file just include this in your vimrc file
nnoremap ac :cd %:p:h :! javac %:t :! java %:t:r
Let me run you through how this code works. When you press the leader key followed by a and c (\ac), the code changes to the directory of the current file that is open in vim(presumably your main). Then, the code compiles yourfile.java (%:t). Finally, the code runs your main file yourfile (%:t:r). < CR > stands for carriage return, which is the equivalent of enter. This approach would work for developing projects with multiple classes as well, because you could add more code to the above line to make it compile other classes before running main.