Accepted answer



then your content assist shortcut key.

enter image description here

You can also add a main method from the class creation wizard. There's a checkbox to have it put in a main method for you. – rfreak


I am on mac and I use TextExpander to create snippets of frequently used codes. I know I am going bit off your question but I am sure this will be very helpful.

You can create snippets of code and assign them keywords. This works with any programming language and in any editor. You just need to type the keyword and your snippet will be auto loaded.

For eg. for my main method I have created keyword jmain. So everytime I need main method I just need to type jmain and the code will be loaded. You can also control the placement of cursor.



In Eclipse you can first type "main" then ctrl+/ and it can be finished automatically.

And In windows Eclipse, you can type "main" , and then alt+/ ,it will be finished automatically!


There are two easy way to add main method in your class. 1. While creating class there is an option - public static void main(String[] args) option - select the check box.

enter image description here

  1. After creating class also you can add main method. type main and press ctrl+space - the [main - main method] option will be displaying - select it.

enter image description here


This is just main and Ctrl+Space.


type ma and then press ctrl+space


type m and then press ctrl+space.

Related Query

More Query from same tag