Welcome to the Joint-Venture Blog from Fabio Cortesi and Stefan Jäger.
Everybody, who’s working with Eclipse is knows the Content Assistant (better known as Code Completion). Just press CTRL + Space, and every possible piece of code gets completed.
But did you know, that Eclipse is also capable of using templates. Templates can be defined in Window – Preferences – Java – Editor – Templates.
For example, instead of typing the main function every time manually, just type main and press CTRL + Space, choose the template main and press Enter. The whole main method is created.
Interesting default templates are:
sysout: creates a System.out.println() entry
runnable: creates a complete Runnable inner class
public_method: template for a public method (same with private, default, and so on)
Of course, you also can define your own template. E.g. for an EJB 3.0 stateless or message-driven bean!