Mar 23 2011

Eclipse best practices

Category: English posts,Miscellaneous,TechnicalIuliana @ 16:23

1. Put in eclipse.ini (after -starup line and it’s argument)
-vm
[$JAVA_HOME]bin\javaw.exe

eclipse.ini sample:


-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110124-0830.jar
-vm
c:\Program Files\Java\jdk1.6.0_24\bin\javaw.exe
–launcher.library
[etc]


2. Don’t overgrow it!
Don’t install all the plugins you think you might need! When you install Eclipse think about what you want to do with it and install exactly those plugins. As gets bigger Eclipse gets slower and also needs more CPU power and memory to run. So keep it simple!
If you work on multiple projects that have only Java in common, I dare to recommend you to install multiple instances and customize each one accordingly.
For example:

  • The icon named Spring IDE is an Eclipse IDE for Java EE Developers with Spring IDE and M2Eclipse Maven plugin. I use it to develop projects using Spring which run on Tomcat and are build with Maven.
  • The icon named Scala IDE is used for developing… (what else?) Scala projects. It the smallest Eclipse I could find with Scala plugin installed.
  • The icon named JBoss Tools is used for developing projects that run on JBoss 6 and use all JBoss has to offer (Drools, RichFaces)
  • The icon named GlassFish Bundle is exactly what it sais it is, Eclipse GlassFish Bundle, and I use it for any projects that need a GlassFish server to run.
  • The icon named INDIGO is for Eclipse Indigo, it is the newest version of Eclipse, it is not stable yet, but I was dieing to test it. :)

3. Do not limit the console output if you don’t store your logs into external files!
Unless you have a really slow machine, in which case at least increase the size of the console buffer to 1.000.000 (default is is set to 80.000)
4.Color it!
Actually it is not all about color. The size, the font family, etc – everything matters. When you are moving into a new house you decorate it to feel comfortable, don’t you? Well, it applies to code editor editors to, because you code better and faster when you are comfortable with your environment. So don’t be afraid to experiment with all Eclipse has to offer when it comes to decorations.
4.Use code templates Eclipse comes with some code templates already defined, these are groups of characters that you can write, hit <Ctrl + Enter> and they will be replace with a piece of code.

Predefined templates : sysout, syserr  for java language (See image below how you can find then and how are they defined)

You can edit the existing ones or create yours. I usualy rename sysout to sout, syserr to serr and I add a template for iterating on generic lists and maps.
5. Use key groups Eclipse uses groups of 3 keys when you want to do something without clicking an option from the menu. Probably the guy that had to develop this part loves developing in Joe too. :)

For example, to run a java application you click on the tab where the file with a main method in it is and then you type Alt+Shift+X and then J. That J letter is the one that tells Eclipse that you want to run a java application. (not an applet or a servlet on a server or others possbile) I find it more practical then always clicking or selecting options to run stuff from the menu. If you don’t like the three letters commands you can change them, but beware not to override stuff!
(I remember in my early years of Eclipse I replaced Alt+Shift+X, J with F5, I was working the in Visual Studio so it was practical, but in Eclipse F5 is used for refreshing, so by overriding this setting, I had to refresh my files or projects by clicking right and clicking again the Refresh option. So I gained nothing. )

This is all I can think of right now. If I remember anything else, I ‘ll update this and change the timestamp. I hope it is useful. I hope I’ll have the time to write an article about most useful key combinations used in Eclipse soon.

Tags: , , ,

4 Responses to “Eclipse best practices”

  1. a says:

    1. don’t install svn tools under eclipse

  2. costelush says:

    Subclipse works great for me, never had any problems with it. Too bad I can’t find a good bazaar plugin too, because I hate working on command line under linux.

  3. costelush says:

    PS: seaqxx, did you ever try F11 / CTRL + F11 ? These are the defaults to debug or run a program with the eclipse for windows (it defaults to the last ran class or to the current class, if it has a main method). For Alt+Shift+X, J you need 4 fingers… this is a little too much for me :P

  4. Iuliana says:

    I agree, Subclipse is the Svn Eclipse plugin I would recommend too. About key groups, when you use Linux and Joe or Emacs, 3-4 keys is pretty normal. :)

Leave a Reply