Eclipse plugin dependency on SWT classes not being resolved
Asked Answered
T

4

5

I have an eclipse plugin project which uses some swt objects, eg -

import org.eclipse.swt.widgets.Composite;

When I try to compile it with the 'Target Platform' set to 'Running Platform (Active)', it compiles fine and I dont need to import any swt specific plugins.

However, I created a target platform with Eclipse 3.6.0 and if I set it as the active platform the project has compile errors wherever swt classes are used and cannot resolve them.

Which plugin should I add a dependency to, to resolve these errors?

I tried adding 'org.eclipse.swt' but that does not seem to help.

Twophase answered 21/12, 2010 at 9:58 Comment(0)
T
6

I figured it out. I was trying to compile against a 32 bit target platform on a 64 bit OS, so the filters were not matching the SWT libraries until I set them manually from the target platform preferences.

Twophase answered 21/12, 2010 at 10:5 Comment(3)
Oh, God, thank you very much! I was going nuts with dozens of not resolved SWT components erros. You saved my day.Boondocks
Window -> Preferences -> Target Platform -> Edit -> Environment -> set Architecture to "x86". worked for meZink
I have the same problem but the solution did not work for me.Thenar
M
9

I had the same problem. In my case, I had a missing dependency and I asked Eclipse to locate the plugin for me.

After the plugin was found on some p2 site, I saw "Resetting Target Platform" in the progress view.

After that, a lot of plugins were broken. Checking the target platform (Window -> Preferences -> Plug-in Development -> Target Platform -> Edit), the field "Architecture" had changed from x86_64 to x86.

Changing the value back and clicking on "Finish" did reset the TP once more and the errors went away.

Makalu answered 21/4, 2011 at 12:1 Comment(3)
How does one ask Eclipse to find missing dependencies?Coble
Use the context menu in the "Problems View" or Ctrl+1.Makalu
I have this problem but my target platform was already set to x86_64.Thenar
T
6

I figured it out. I was trying to compile against a 32 bit target platform on a 64 bit OS, so the filters were not matching the SWT libraries until I set them manually from the target platform preferences.

Twophase answered 21/12, 2010 at 10:5 Comment(3)
Oh, God, thank you very much! I was going nuts with dozens of not resolved SWT components erros. You saved my day.Boondocks
Window -> Preferences -> Target Platform -> Edit -> Environment -> set Architecture to "x86". worked for meZink
I have the same problem but the solution did not work for me.Thenar
T
0

For me, I needed to add external jars corresponding to the SWT libraries to my build path. Moreover, I needed to add ones specific to my platform (Windows).

I added the following jar to my project build path:

$USER/.p2/pool/plugins/org.eclipse.swt_3.106.1.v20170926-0519.jar
Thenar answered 8/11, 2017 at 17:31 Comment(1)
Why did you add the same JAR twice? Your solution is probably wrong and just hides a mistake you made elsewhere. You really need to check your target platform. When the plugin is in the target platform, Eclipse should be able to figure everything out.Makalu
E
0

In case anyone runs into this problem on Mac M1 arm processor: I ran into this problem when upgraded eclipse to use arm versions of jdk, etc. To fix, had to manually change the target to aarch64 for eclipse via eclipse/preferences/plugin development. The default was incorrect and was x86 target.

Educator answered 30/10, 2022 at 21:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.