1

I'm trying to build a plug-in but I have the following error:

The project was not built since its build path is incomplete. Cannot find the class file for org.eclipse.swt.graphics.Image. Fix the build path then try building this project

How do I fix this error?

I tried to add the SWT JAR for Linux/gtk/x86_64 but that doesn't fix the error. Apart from that, I don't want to use a platform specific dependency (for obvious reasons).

I also tried to add org.eclipse.swt but I can't select that in the dialog for "Required Plug-ins". I can add it to "Automated Management of Dependencies" but there, it has no effect.

"Imported Packages" doesn't let me select anything from org.eclipse.swt :-(

So the question is: What is the correct way to tell Eclipse to shut up and find the correct SWT plugin later?

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • I had same problem when I created workspace in windows & opened in eclipse under linux... which was my fault – To Kra May 22 '15 at 14:28

2 Answers2

5

I suppose you're building a plug-in and not "just" a Java program that depends on SWT.

I also suppose you have tried all the obvious, such as cleaning the project, restarting Eclipse, etc...

When I see this, it is very often because the target platform is not correct. The target platform must not only contain the SWT plug-in, but also all the SWT fragments for the platforms, you want to use/build for...

(If this is the problem, please note that there are other plug-ins with platform specific fragments...)

Tonny Madsen
  • 12,628
  • 4
  • 31
  • 70
  • I guess that means I have to add the delta pack to my target platform. But even after adding the delta pack, the error doesn't go away. Which dependency do I have to add where in the plug-in editor to say "I'll have SWT eventually"? – Aaron Digulla Jul 01 '11 at 09:34
  • The primary question here is whether you have set up a specific target platform for your application. That can only be recommended! If so, then add the relevant fragments - possibly everything from the delta pack - and reload the platform. If not... either create a target platform with the relevant plug-ins or simply reload the existing IDE platform... – Tonny Madsen Jul 01 '11 at 09:46
  • I don't have an application; just a plugin which I will later install in Eclipse. What is a fragment? How do I add it? How do I know which plug-ins are "relevant"? How do I "reload" the existing IDE? – Aaron Digulla Jul 01 '11 at 14:33
  • 1
    Application or plugin does not matter. You should have a target platform for both... read this: http://eclipse.dzone.com/articles/creating-eclipse-rcp-target Fragments - read this: http://wiki.eclipse.org/FAQ_What_is_a_plug-in_fragment%3F and http://stackoverflow.com/q/673908/796559 – Tonny Madsen Jul 01 '11 at 20:33
  • What specifically do I have to add to my plugin.xml or MANIFEST.MF to tell it that SWT will be available? Or should it be enough to have SWT in my current active target platform? Something else which I noticed: In the page "Content", I can see about 40 "org.eclipse.swt*" entries listed but only two (linux x86/64 and org.eclipse.swt) are selected. What does that mean? – Aaron Digulla Jul 04 '11 at 15:18
  • 2
    Your `MANIFEST.MF` must have a dependency on either ´org.eclipse.ui` or `org.eclipse.swt`. Your target platform - the "Content" page - must include ´org.eclipse.swt` and `org.eclipse.swt.` - e.g. `org.eclipse.swt.linux.x86_64` - where platform is your platform... Please the dzone reference above... it should explain all this... – Tonny Madsen Jul 04 '11 at 19:08
  • The dzone article only explains how to setup a target; it doesn't explain why I can see "org.eclipse.swt" in "Target Content" but why Eclipse doesn't allow me to select it in my plugin project :-( – Aaron Digulla Aug 04 '11 at 12:30
  • One final - possibly stupid - comment: have you activated the target platform? – Tonny Madsen Aug 04 '11 at 15:32
  • Yes. @*: It's probably a bug. I have the plugins in the target platform, it's "active" and I can find them when I search in the preferences dialog. The "Add dependency" dialog doesn't offer them but I can add "org.eclipse.swt" to MANIFEST.MF without an error. When I open that and then edit the dependency, the dialog offers the version 3.7.0.XXX. Strange. – Aaron Digulla Aug 08 '11 at 11:22
  • I was having the same problem as OP when I created a new plug-in project using one of the built-in templates. Creating a target definition file (with the "New -> Target Definition" command) solved it for me. – Lii Dec 31 '15 at 14:52
3

I had the same issue and fixed it by editing the Target Environment settings.

By default, the Windowing System was set to: cocoa.

I've entered the following settings:

  • Operating System: linux
  • Windowing System: gtk
  • Architecture: x86