Add some magic to Eclipse

Saturday 2011-07-30

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.

Read the rest of this entry »


^H(eaven) key binding in Eclipse

Sunday 2011-06-19

Eclipse File Search WindowAs a long time user of Eclipse, I have never understood the any of the tabs of the Search panel in Eclipse. JavaScript search, Java Search, Remote Search, they all make no sense to a modern man who is used to a single search box which searches everything. So I always use the “File Search” Tab, which does exactly what I want 99% of the time.

File Search always requires mouseclicks. To open the Search window and select the correct tab. It was not until recently that I realized that I could actually reassign the ^H (Control – H) key combination to pop up the File Search tab. If you are an avid Eclipse user you’ve probably already done this, or know how to do this. If you are new to eclipse, or lazy like me, read on to see how you can re-map this key binding.

Read the rest of this entry »


Changing the Order of your UnitTests

Friday 2011-04-01

A few months ago we had a problem where Eclipse could not automatically run all jUnit unit tests in a package if that package references a class called “enum”, which is a reserved word in Java 1.6. I’ll spare you the details, but we were forced to create a TestSuite. Normally we avoid this construction because it’s easy to create a new unit test and forget to add it to the correct TestSuit. So as a workaround we wrote some code which could build and return a TestSuite dynamically. Right-click in eclipse, select “Run as Unittest”, sit back and enjoy.

Lately this piece of code came in handy while testing another application, which required the removal of data from a database. Yes I know, Unittests should maybe not depend on databases because it leans towards integration testing, but here we are, and I need to solve it. I used the old TestSuite code and changed it so that the TestCase I needed to run first was singled out, while still maintaining the functionality of auto-detecting testcases in the source folder.

Read the rest of this entry »


Your Maven Java WEB project in Eclipse WTP

Saturday 2011-01-29

In our company, all Java projects are setup with Maven configuration so that after a “mvn eclipse:eclipse” any developer is generally good to go. One of these projects was a web project but would not transform into a WTP project. By running “mvn eclispe:eclipse” it became a Java project, but could not be added to a Server in Eclipse. It was not a WTP project.

I learned that the author of the project tried but never got the WTP plugin to work properly. Using the Google, I found more people who are having the same problem converting their existing Maven Java Web projects in Eclipse into a WTP project. There are even a few desperate articles describing how to edit your .project and .classpath files. Oh dear. This calls for an article on http://www.rolfje.com.

Read the rest of this entry »


Eclipse 3.4.1, OSX and Java 1.6

Sunday 2008-12-28

Eclipse application icon

I recently downloaded Eclipse 3.4.1 for Mac OSX, and tried starting it using the eclipse.app icon. It did not work, and I noticed a message in /var/log/system.log telling me that the JVM could not be loaded.

Read the rest of this entry »


Eclipse on Intel Macs

Wednesday 2006-05-03

Eclipse looks really nice on OS X. I can tell, I have it running on my mac Mini duo core. If you have problems getting it to start, and the logfile complains about linker errors, chances are you have the PPC version of the eclipse app file. To check this, Ctrl-click on the eclipse.app file. If it doesn’t say “(Universal)” somewhere next to “Type:”, then you need to download a newer version. Get the Eclipse 3.2 RC2 or higher, and make sure you download the “Mac OSX (Mac/Carbon)” version.

Read the rest of this entry »