Tuesday, December 11, 2012

Fix: Add Apache Derby Nature in Eclipse does nothing

Tonight I had a strange issue with Eclipse: adding the Apache Derby nature to an Eclipse project wasn't working. Ordinarily, (provided that the Apache Derby Eclipse plugin is already installed) right-clicking a project and choosing Apache Derby->Add Apache Derby Nature to a project will do just that, enabling additional features such as starting or stopping the Derby network server.

This time, however, choosing that option appeared to do nothing. Rather than a menu full of commands, I was given only the option "Add Apache Derby Nature" in the Apache Derby context menu, which is what I had previously selected. I tried several times to add the nature in this manner, but to no avail.

The fix turned out to be simple. After grepping the directory of another project where I had successfully used Derby, I found that the change should have been reflected in my project's .project file.

The fix: if the Apache Derby nature isn't correctly added to a project through the Apache Derby menu, it can be done manually by editing the .project file (which is in the root directory the project). This is an XML file.

Find the <natures> node and add this line:


Here's how the entire <natures> node looks after the change in my project:


Then, just save the file. Problem solved.