简体   繁体   English

Eclipse 插件 - 无法解析 Swing 类引用

[英]Eclipse Plugin - Unable to Resolve Swing Class References

( Disclaimer : Neither of the following are true: (1) Java is my forte, and (2) I'm a pro at Plug-in development.) 免责声明:以下均不正确:(1)Java 是我的强项,并且(2)我是插件开发的专家。)

My Eclipse plug-in project includes 5 plugins.我的 Eclipse 插件项目包括 5 个插件。 2 of them compile just fine.其中2个编译得很好。 The 3 that don't include dependencies on classes in the org.eclipse.swt.widgets or org.eclipse.swt.graphics packages. 3 不包含对org.eclipse.swt.widgetsorg.eclipse.swt.graphics包中的类的依赖关系。 The (extremely annoying) compile-time error message is: (非常烦人的)编译时错误消息是:

The type org.eclipse.swt.widgets.Control cannot be resolved. 
It is indirectly referenced from required .class files.

Now, I've been over this workspace with a fine-toothed comb.现在,我已经用细齿梳子浏览了这个工作区。 I've checked and rechecked the following:我已经检查并重新检查了以下内容:

  • Classpaths.类路径。 Check!查看! (The appropriate JRE and JDK are on the Windows PATH.) (相应的 JRE 和 JDK 位于 Windows PATH 中。)
  • Dependencies.依赖性。 Check!查看! (All libraries are included.) (包括所有库。)
  • Build Path.构建路径。 Check!查看! (Using the right JRE, importing all necessary libraries, build order is correct.) (使用正确的 JRE,导入所有必要的库,构建顺序是正确的。)
  • Imports.进口。 Check!查看! (Yep. The correct libraries are imported as shown in the dialog.) (是的。正确的库被导入,如对话框中所示。)
  • Manifest.MF.清单.MF。 Check!查看! (Double-checked the manifest file to make sure the paths are right. All three projects are referencing the same file from the same JRE.) (仔细检查清单文件以确保路径正确。所有三个项目都从同一个 JRE 引用同一个文件。)
  • Plugin.XML.插件.XML。 Check!查看! (Yeah, the file is fine.) (是的,文件没问题。)
  • .ClassPath file. .ClassPath 文件。 Check!查看! (No problem here, either. The classpath files are all fine.) (这里也没有问题。类路径文件都很好。)
  • build.properties file. build.properties 文件。 Check!查看! (No surprises here, either.) (这里也没有惊喜。)

I've googled and stackoverflowed till my eyes are bleeding.我用谷歌搜索和计算器溢出,直到我的眼睛都在流血。 None of the typical suggestions seem to be helping.典型的建议似乎都没有帮助。

I'm certain however, that the usual truth is going to prove to be the case here.然而,我敢肯定,通常的事实将在这里证明。 ( All things being equal, the answer is usually something simple, stupid, and painfully obvious. ) (在所有条件相同的情况下,答案通常很简单、愚蠢且显而易见。

Can someone kindly suggest something I haven't yet looked at?有人可以提出一些我还没有看过的东西吗? I'm more than willing to provide whatever information you may require.我非常愿意提供您可能需要的任何信息。

PS And might I note that there are way too many places to look to configure dependencies for plugins? PS我可能会注意到,有太多地方可以去看看配置依赖关系的插件? Great googly moogly.很棒的googly moogly。

There is a disconnect between your target platform and the swt plugins available in your environment.您的目标平台与环境中可用的 swt 插件之间存在脱节。

  • In eclipse, go to Help -> Preferences -> Target Platform.在 Eclipse 中,转到帮助 -> 首选项 -> 目标平台。
  • Select your target platform and click on [Edit...].选择您的目标平台,然后单击 [编辑...]。
  • In the dialog, select the "Environment" tab.在对话框中,选择“环境”选项卡。

The fields in the "Target Environment" will be used to load your swt plug-in. “目标环境”中的字段将用于加载您的 swt 插件。 The any field not filled in, will default to the values detected for the current environment.未填写的任何字段将默认为为当前环境检测到的值。

In your case, you have an win32.x86 swt jar.就您而言,您有一个 win32.x86 swt jar。 If you are running on 64-bit windows, and the Architecture field is blank, your 32-bit swt jar will not load.如果您在 64 位 Windows 上运行,并且 Architecture 字段为空,则您的 32 位 swt jar 将不会加载。 You have two options to fix any discrepancies:您有两个选项可以修复任何差异:

  1. Install an eclipse platform pack.安装 Eclipse 平台包。 It will contain all the swt jars for all the platforms.它将包含所有平台的所有 swt jar。
  2. Make the "Target Environment" fields match the swt jar you have available.使“目标环境”字段与您可用的 swt jar 匹配。

That basically means that it is an indirect unsatisfied dependency: a class from a library you're using needs some other class to be on the class-path :)这基本上意味着它是一个间接的未满足的依赖项:您正在使用的库中的类需要一些其他类在类路径上:)

Now I have no idea how you manage your dependencies (maven or manually) but as a starting point you could use jarfinder.com to find and download the necessary library if you don't have it already: http://www.jarfinder.com/index.php/java/info/org.eclipse.swt.widgets.Control现在我不知道您如何管理您的依赖项(maven 或手动),但作为起点,您可以使用 jarfinder.com 来查找和下载必要的库(如果您还没有): http://www.jarfinder。 com/index.php/java/info/org.eclipse.swt.widgets.Control

If you're using Maven, you should look in the logs as it tries to download all the necessary libraries, dependencies included.如果您使用的是 Maven,您应该查看日志,因为它尝试下载所有必要的库,包括依赖项。 So if anything went wrong it should point out in the log a connectivity problem or the impossibility of downloading an artefact for some other reason.因此,如果出现任何问题,它应该在日志中指出连接问题或由于其他原因无法下载人工制品。

  1. open eclipse IDE打开日食IDE
  2. select menu project->clean选择菜单项目->清理
  3. close eclipse IDE关闭 Eclipse IDE
  4. delete .swt from /home/user/.swt从 /home/user/.swt 删除 .swt
  5. re-open eclipse and fix message重新打开eclipse并修复消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM