Tomas Kramar lives in Slovakia, where he works for a company developing software for a major local telecommunication provider. He is also a student at the Slovak University of Technology. Tomas has posted 6 posts at DZone. You can read more from them at their website. View Full User Profile

Effective Eclipse: Setup Your Environment

02.08.2008
| 37202 views |
  • submit to reddit

Today, I was taught an important lesson. The lesson of effectiveness. I was attending a presentation, called "Python Django: Advanced web application in 40 minutes". The guy was a geek, he was writing the code in a very basic vim installation. I bet, that if he used something better (no offense, it was really basic installation and he was apparently no vim master) he could crack it in half the time. It was an "oh, I made a typo here" presentation. It was then, when I realized that you really need a good editor if you want to be productive.

Choose your tool

Just do it. Find what suits you best and use it. I found Eclipse.

Basic setup

The first thing you should do, is to set up your font. If you are using Windows, you are lucky, as the font looks probably good and is well readable. If you are using Ubuntu like me, you might have less luck. When I first started eclipse, I was stunned. The font was big and crappy.

But not for too long.
Open: Window->Preferences->General->Appearance->Color and Fonts->Basic->Text Font and change the font size to 8. Much better now. The font used is called Monospace, some people recommend Bitstream Vera Sans Mono. This is how it looked before and how it looks now.

Before:

This is how it looked before..

After:

..and this is how it looks now

I recommend lowering the font size for your whole desktop. You will be surprised how much more can you see now. You can improve the font rendering too.

Don't be greedy

Eclipse is running with very small memory by default, but there is really no reason to be greedy. Just give your toy what it needs. Fire up the text editor, open eclipse.ini and enter:

-vmargs -Xms512M -Xmx1024M -XX:PermSize=128M -XX:MaxPermSize=256M

The -Xms option specifies the minimum and -Xmx the maximum heap size. The same holds for PermSize and MaxPermSize. Heap is that part of memory, where all your objects live. PermGen means "Permanent Generation" and it is a part of memory where all permanent objects are stored. By permanent, I mean those, which are not going to be garbage collected (for example Strings, classes etc.). Here you can find a better explanation of what PermGen is.
If you are running a linux box, you might experience OutOfMemoryError-s if you do not adjust memory size. The values provided above are only for example, you should enter the values appropriate to your RAM size.

You can further tune the performance by providing additional arguments. In his article, Jim Bethancourt recommends using Throughput garbage collector (-XX:+UseParallelGC), Robi Sen recommends using CMS Collector (-XX:+UseConcMarkSweepGC) as more effective.

Help, I am giving the crap all my memory and it still keeps OutOfMemoryErroring!


The reason is that you are simply not giving it enough memory. But don't worry, you don't have to buy another memory module (well, unless you have 128MB RAM). It is possible that you have made a typo in eclipse.ini, or maybe you used wrong eclipse.ini or maybe it simply doesn't work. I cannot tell you how to fix it, but I can tell how much memory are you giving it.

Open Window->Preferences->General and check the "Show heap status" checkbox. You should now see the memory status in the bottom right corner.

Memory meter

If you see values which correspond to the values you entered, everything should be fine.

Set it up

You should really take a time to walk through all the options under Window -> Preferences and customize your eclipse installation. I am going to list few ba

General

Always run in background: when eclipse is doing something time consuming, it will bother you with a modal popup window showing the progress of a task. I used to dismiss the popup with "Run in background" button. I am usually not interested in watching the lazy progressbar. If you enable this option eclipse will no longer bother you, and all tasks will run in background by default. There is nothing worse than breaking your workflow with messages: Hey I am building, can you see?

Appearance: You can set various font related options here. If you are interested, you can change the position of tabs from top to bottom.

Editors->File associations: if you have some exotic extension you can map it to the appropriate editor here. If you have xml file called myfile.exotic you can map .exotic extension to the xml editor.

Editors->Text Editors -> Show line numbers: If you like, you can see line numbers. Very useful.

Editors->Text Editors -> Spelling:
Eclipse comes bundled with a spell checking turned on by default. This is a good idea and I really liked it, until I opened localized messages for my web application. Every word in my file was marked as misspelled, I was looking at an yellow sea of warnings, editor became quickly unresponsive as it wasn't able to handle hundreds of spelling errors. I had to turn this feature off, at least until some kind of ignore list is implemented or some good folk creates dictionary for my language.

Java

Java->Code style: Under Cleanup and Formatter are code formatting settings which are applied everytime the file is saved. If you tune it, it can save you much time.

Java->Code style->Code templates: Here you can find and edit various templates. The only thing I do here is changing the "new Type" template to show my real name as author instead of my operating system username.

Run/Debug

Run/Debug->Launching:
In previous Eclipse releases if you hit the run button, the last launched application was started. In Eclipse 3.3 this behavior changed a bit, and the selected resource gets launched. I found it annoying as I usually have only one runnable class. You can switch to the old style by choosing the right option under Launch Operation fieldset.

I know I am repeating myself, but it is essential that you walk through the options and set it, such that it works with you, not against you.

References
Published at DZone with permission of its author, Tomas Kramar. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Robert Hicks replied on Sat, 2008/02/09 - 9:12am

A font size of 8?! I am 42 years old. There is no way I am setting a font size that low.  : )

Rick Ross replied on Sat, 2008/02/09 - 10:10am in response to: Robert Hicks

[quote=sigzero]A font size of 8?! I am 42 years old. There is no way I am setting a font size that low. : )[/quote]

I'm going to have to agree with you on this one, Robert! I think we're being subjected to age discrimination! Who can we sue? LOL

At 48, I find that one of the first things I do in these IDE's is to increase the font size to reduce eye fatigue. I guess being 48 may also help with being more comfortable to invest in niceties like a large monitor to make this practical. All things in time, right?

Rick

Tomas Kramar replied on Sat, 2008/02/09 - 10:21am

The font real size does not depend only on font "size", but also on dpi. The font size 8 in Ubuntu (or Gnome, generally) is equal to font size 10 in Windows. The default is just too big for my young eyes :)

Matt Raible replied on Sat, 2008/02/09 - 12:12pm

I use a 14pt font in iTerm and it's much easier to read for me. Combine that with a 30" monitor, lean back and enjoy!

Rainer Eschen replied on Sat, 2008/02/09 - 6:05pm

Robert and Rick I've to agree (42 in August this year ;-)). Resolutions above 1024x786 need a change in font size, else I wouldn't see the wood for the trees. 

Thanks for the "newType" tip. I tried to find a solution for this without success.

Springsteam Blog - Next Generation Java Development

Fred Grott replied on Sat, 2008/02/09 - 8:13pm

For those of us over 40, I found wide screen LCDs help :)



Fred Grott(aka shareme) sometimes a JavaZone(JavaLobby) and EclipseZone contributor. Top visited blog on Jroller.com at: http://www.jroller.com/shareme/

Jeroen Wenting replied on Mon, 2008/02/11 - 2:01am

hmm, I've a 17" widescreen laptop running at 1400 wide and a 15" running at 1680 wide, the 15" is less tiring on the eyes than the 17"...

Iwema replied on Mon, 2008/02/11 - 7:15am

1600x1200 @ 20" LCD, and I prefer the 8 sized font as well, I really like the overview I get. I recently wrote two articles about Eclipse as your IDE as well:

Install your Eclipse plugins in a different directory

5 Eclipse plugins I can’t live without

Kaj Kandler replied on Wed, 2008/02/13 - 3:37pm

Thanks, Iwema,

installing Eclipse plugins in different directories make sit much easier to keep streamlined (non bloated) Eclipses for diffent project needs and still share the plugins. It also helps testing out new plugins with shaky foundations (crashing) w/o effecting established stable contexts.

:-( although, these days Even WST is shaky like a man with Parkinson.

K<o>

Buys, teaching OpenOffice.org with videos

Adobex replied on Fri, 2008/03/07 - 9:03am

Java->Code style->Code templates: Here you can find and edit various templates. The only thing I do here is changing the "new Type" template to show my real name as author instead of my operating system username.

Personally, I prefer to set the eclipse.ini with that property :
-Duser.name=Bidule
Of course you can also set it by the Eclipse shortcut...
;-) 

Adrian Kuhn replied on Thu, 2008/10/16 - 9:38pm

There are now toolbar buttons to change the font-size with a single-click

They are quite handy when giving a demo to increase the font size ... an of course for all of us that one day feel 48yo and the other 16yo :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.