3

我正在尝试编译Eclipse JDT - 抽象语法树 (AST) 和 Java 模型 -使用命令行的教程。

plugins我根据eclipse indigo目录中的名称匹配提出了这个命令行。

javac -cp .:\
org.eclipse.core.runtime_3.7.0.v20110110.jar:\
org.eclipse.equinox.common_3.6.0.v20110523.jar:\
org.eclipse.core.commands_3.6.0.I20110111-0800.jar:\
org.eclipse.core.resources_3.7.100.v20110510-0712.jar:\
org.eclipse.jface.text_3.7.1.r371_v20110825-0800.jar:\
org.eclipse.jdt.core_3.7.1.v_B76_R37x.jar:\
org.eclipse.jdt_3.7.1.v201109091335.jar \
SampleHandler.java

问题是我仍然得到这 4 个错误。

SampleHandler.java:19: cannot find symbol
symbol  : class Document
location: package org.eclipse.jface.text
import org.eclipse.jface.text.Document;
                             ^
SampleHandler.java:28: cannot access org.eclipse.core.runtime.jobs.ISchedulingRule
class file for org.eclipse.core.runtime.jobs.ISchedulingRule not found
    IProject[] projects = root.getProjects();
                              ^
SampleHandler.java:87: cannot find symbol
symbol  : class Document
location: class handlers.SampleHandler
    Document doc = new Document(unit.getSource());
    ^
SampleHandler.java:87: cannot find symbol
symbol  : class Document
location: class handlers.SampleHandler
    Document doc = new Document(unit.getSource());
                       ^
4 errors

我有更多错误,但在这个提示的帮助下,我可以添加org.eclipse.equinox.common_3.6.0.v20110523.jar以删除许多错误。

似乎 jar 名称可能无法反映包导入名称。我怎么知道应该添加哪些 jar 文件来消除错误?

4

1 回答 1

1

我发现http://www.jarfinder.com非常有用。使用这个站点,我可以给出类名来查找可用 Eclipse 版本的 jar 名称。

例如,我可以搜索 org.eclipse.jface.text.Document

在此处输入图像描述

通过单击类,我可以识别 jar 文件的名称。

在此处输入图像描述

即使最新的 Eclipse 信息不可用,我也能猜到 jar 名称。

于 2012-10-02T04:38:19.460 回答