How do you get Eclipse to auto-generate a main method for a new Java class?

Type main and press ctrl+space. The eclipse content assist will pop up with main method. Press enter.


"what can i do to make it appear automatically? "

  • Go to create New Java Class dialog
  • See a part that says "Which method stubs would you like to create?"
  • check public static void main(String[] args)

enter image description here


I think the best practise is to use only keyboard. It makes workflow a lot faster.

  1. Create new java class with Ctrl+n
  2. on dialog box, enter its (class) name
  3. use (left)Alt+v to easily tick checkbox for - public static void main(String[] args)
  4. then press [enter] Finish and voila class is ready...

Tags:

Java

Eclipse