Main creation shortcut in NetBeans

Hello everyone,

Maybe You used Eclipse some days (and still use it ;)) and appreciate the way You can create the main method. In Your class, You enter “main” and then press Ctrl+Space and it generates the body of Your main method.
Using NetBeans, it isn’t available by default. But some times ago, I found a way to do it in the similar way that Eclipse does πŸ™‚ So let’s see how.

You have to create a code template, but don’t be affraid, it’s really simple. First go to the preferences of NetBeans, then in the “Editor” part and click on the tab “Code templates”. You should be there :

Image 1

Then click on “New”. In the window, type the text You have to write. It’s Your shortcut πŸ™‚ For the main method generation, type “main” πŸ™‚ It’s not original but instinctive πŸ™‚
In the list, Your new abbreviation is selected. In the text area called “Expended Text”, enter this :

public static void main(String[] args) {

You’ve successfully created a main template πŸ™‚
Now in Your class, just type “main” and press the Tab button, and Your main body will be created πŸ™‚
It’s nice, it’s simple, it’s Java πŸ™‚


5 Responses to Main creation shortcut in NetBeans

  1. Andre Lohan says:

    Hello! You can try the following to get the same result:


  2. Hello!
    Thanks for the tip, I didn’t know it.

  3. akash says:

    u rock

  4. stefanbanu says:


  5. umak says:

    Thank you! great

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: