This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "java code templates [Eclipse]" Watch "java code templates [Eclipse]" New topic
Author

java code templates [Eclipse]

asirob civokviz
Greenhorn

Joined: Jun 12, 2004
Posts: 24
Hi,
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{

doPost(request,response){}

doGet(...){}

...

}

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

Thanks
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32507
    
214

Asirob,
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: java code templates [Eclipse]
 
It's not a secret anymore!