How do I create and use a Java template?
Author: Deron Eriksson
Description: This tutorial describes how to create and use a Java template in Eclipse.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)
(Continued from page 1)
This automatically inserts the template code into my Java file, as shown.
Let's finish things by resolving the import. I hit Control-Shift-O to 'organize imports'. There are two Logger classes in the build path, so I select the desired one, org.apache.log4j.Logger.
Our import for the Logger has been created. I save the file.
Java templates can be a great time-saver. As you can see, in a couple clicks, you can automatically insert useful code into your Java files.