It's not a secret anymore!
The moose likes IDEs, Version Control and other tools and the fly likes java code templates [Eclipse] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "java code templates [Eclipse]" Watch "java code templates [Eclipse]" New topic

java code templates [Eclipse]

asirob civokviz

Joined: Jun 12, 2004
Posts: 24
I am pretty new to Eclipse and I'm trying to find plugin or a feature
of that IDE that can automatically generate templates for java classes.
For example when I create new servlet it would be nice if Eclipse
create common code for all servlets:

public class ServletName extends HttpServlet{





Anyone knows how to find this plugin or configure Eclipse to do this???

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33134

I can think of ways to do it in two steps.

Approach 1:
a) New class --> extends HttpServlet
b) Overwrite/implements methods --> pick those two

Approach 2:
a) New class --> extends HttpServlet
b) Create a template called "servlet" to expand to the two methods. Templates are defined in the Eclipse preferences under the java section.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: java code templates [Eclipse]
It's not a secret anymore!