File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Badass: Making Users Awesome this week in the Game Development 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: 31634

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]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: java code templates [Eclipse]