2011-07-15 52 views
0

我正在使用Eclipse Indigo,并且无法编译一些在Ganymede中以前工作正常的代码。我无法导入以下任何类别:无法找到org.eclipse.swt.widgets.XXX的类文件

import org.eclipse.swt.SWT; 
import org.eclipse.swt.custom.CTabFolder; 
import org.eclipse.swt.custom.CTabItem; 
import org.eclipse.swt.layout.GridData; 
import org.eclipse.swt.layout.GridLayout; 
import org.eclipse.swt.widgets.Composite; 

我试图在Eclipse Marketplace中搜索SWT,但找不到该库。另外,我阅读了其他文章,说重建我的项目(我做了),其他人建议下载“JAR”。有谁知道我需要下载哪个JAR?或者如何修复我的构建路径,以便它包含这些SWT库?

类路径(DannyGui应该有两次):提前

<?xml version="1.0" encoding="UTF-8"?> 
<classpath> 
<classpathentry kind="src" path="com.danny.DannyGui.plugin/src"/> 
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/swtgraphics2d.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/antlr/stringtemplate-3.2.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/antlr/antlr-2.7.7.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/antlr/antlr-3.1.3.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/antlr/antlr-runtime-3.1.3.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/antlr/gunit.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JacORB/wrapper-3.1.0.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JacORB/antlr-2.7.2.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JacORB/avalon-framework-4.1.5.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JacORB/backport-util-concurrent.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JacORB/idl.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JacORB/jacorb.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JacORB/logkit-1.2.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JacORB/picocontainer-1.2.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/gnujaxp.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/iText-2.1.3.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/jcommon-1.0.15.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/jfreechart-1.0.12.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/jfreechart-1.0.12-experimental.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/jfreechart-1.0.12-swt.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/junit.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/JFreeChart/servlet.jar"/> 
<classpathentry exported="true" kind="lib" path="C:/DannyGui/DannyGui/com.danny.DannyGui.plugin/third_party_libs/log4j/log4j-1.2.15.jar"/> 
<classpathentry kind="output" path="bin"/> 
</classpath> 

感谢。

+0

我要补充,这是我真正的错误:该项目未建,因为它的构建路径是不完整的。找不到org.eclipse.swt.widgets.Composite的类文件。修复构建路径,然后尝试构建此项目。由于其构建路径不完整,该项目未建成。找不到org.eclipse.swt.widgets.Composite的类文件。修复构建路径,然后尝试构建此项目。 –

+0

你可以发布你的项目的.classpath文件的内容吗? –

+0

添加类路径... –

回答

0

发布的.classpath文件不包含任何可以加载SWT类的地方。这个项目不会像任何版本的Eclipse一样构建。

这听起来像你正试图构建为独立的SWT应用程序(而不是说一个Eclipse插件)。独立应用程序需要类路径上的SWT库。您不会在Eclipse Marketplace上查找SWT,因为您并未在寻找扩展Eclipse的插件。您正在寻找您的项目所依赖的图书馆。您将SWT作为一个zip文件下载,您可以从系统中抽取某个地方。该zip包含.jar文件和作为SWT实现一部分的本机库。

与其给你一个直接的链接,我会告诉你如何找到它。开始在Eclipse平台下载网站:

http://download.eclipse.org/eclipse/downloads/

忽略发展的基础之上。查看最新版本。现在,这将是3.7。跟随该链接到构建页面。寻找SWT底部。下载适合您系统的zip文件。解压缩并从项目的类路径中添加对包含的jar的引用。

+0

好的,我看到了...... - 在Eclipse Package Explorer中右键单击项目,选择属性,然后单击左侧的Java Build Path。 - 单击“添加外部JAR ...”按钮。 - 添加<您的Eclipse Home> \ plugins \ org.eclipse.swt_3.7.0.v3735b.jar和org.eclipse.swt.win32.win32.x86_3.7.0.v3735b.jar(您的主目录是您下载的内容如@Konstantin提到的或者你的Eclipse主目录(如果这些文件在那里),更改特定名称以匹配与你的操作系统和SWT构建相匹配的任何名称)。 - 然后清理并重建您的项目。 感谢@Konstantin的帮助。 –

+0

是的,你可以指回你自己的Eclipse安装,但我不会推荐这样做。这对您决定完成后需要分发的内容没有任何帮助,因此您最终会争先恐后地进行分类。在您的想法中,您将来可以安全地解决一些麻烦并下载单独的SWT发行版。 –