Skip to content

www.rolfje.com

Add some magic to Eclipse

Posted on 2011-07-30 By rolfje No Comments on Add some magic to Eclipse

Templatus Expandum!The top feature of the eclipse IDE is the very impressive refactoring possibilities. It makes code feel like play-doh, allowing you to knead it in any shape way or form you think fits the current situation. A close second to that is the impressive templates and code assist. Yes, Java is verbose, but I think 80% of the characters which make up a Java program was never actually typed. All the readability without the labour, brought to you by eclipse’s powerful templates.

What many people don’t realize is that you can easily add to this magic by creating your own templates. One of the first templates I always add to the environment is the one which adds a private static final log4j logger. I thought it would be great example to share with you.

${imp:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class);

You can add and change existing templates in Eclipse -> Preferences -> Java -> Editor -> Templates. There are other great examples when you scroll through the list, and you can export the templates to a file in your shared SpiderOak folder to have them available on all your machines.

Templates configuration in EclipseRemember to give your templates an easy name so you can quickly invoke them by code completion. Great examples are the existing “sysout” and “foreach” templates. I called mine “llog” with a double-l because “log” collides with too many other code completion possibilities.

Experiment and enjoy your increased productivity.

 

 

Software Tags:eclipse, Java, programming

Post navigation

Previous Post: Replacing Dropbox with Spideroak
Next Post: Fixing Photo Creation Dates

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

           

Recent Comments

  • rolfje on Methode Buijs uitgelegd
  • LinkedIn is at Peak Enshittifaction – Will Chatham's Blog on Linked-In not really Opt-in?
  • Hans j on 1N4148 diode as RF switch
  • Roaming Rhonda on DLNA on OSX, done right
  • Frans on How to fix a Krups XN2001 Nespresso machine

Tags

Anonimatron Apple backup design DIY DRM eclipse environment Fun gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Keynote maven modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software Steve Jobs T-Mobile technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (105)
  • Divorce (1)
  • Electronics (3)
  • Fun (57)
  • Games (7)
  • Hardware (72)
  • Microsoft (18)
  • Racing (14)
  • Software (134)
  • Uncategorized (65)
  • Workshop (20)

Archives

Copyright © 2025 www.rolfje.com.

Powered by PressBook WordPress theme