user3126480
user3126480

Reputation:

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

Does anyone know a reason why my Eclipse does not preload

public static void main(String[] args)

when I create a new class? What can I do to make it appear automatically?

Upvotes: 7

Views: 40635

Answers (3)

zoladp
zoladp

Reputation: 121

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...

Upvotes: 3

Asheesh
Asheesh

Reputation: 463

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

Upvotes: 28

Paul Samsotha
Paul Samsotha

Reputation: 208974

"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

Upvotes: 16

Related Questions