Tag Archives: java

Import error while building Eclipse Plugin in a Java Project

I was trying to build a Java project I got from somebody using the Eclipse Gallileo install. Since the workspaces were different, my Eclipse install was confused about the eclipse plugins jar files, and it threw the following error:
"The import org.eclipse cannot be resolved"
on line: import org.eclipse.core.runtime.Plugin
and other cryptic errors: "BundleContext cannot be resolved to a type"

I resolved this by adding the appropriate jar library files from my eclipse directory. Here’s how I searched which files I needed.

  1. Go to eclipse plugins: cd eclipsedir/plugins
  2. For each suspecting jar, I do jar -tvf filename.jar | grep "searchingforthisClass"
  3. In the end I found my Plugin class: jar -tvf org.eclipse.core.runtime_3.5.0.v20090525.jar | grep Plugin
  4. Right click on the project in Eclipse, choose Properties, under Libraries tab, click “Add External JARs” button, then just locate that jar that you found above.
  5. Rebuild

PS: This is more of a reference for myself than for other Java developers, because this is probably as basic as it gets.