Eclipse 未解决的编译

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10756535/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:15:46  来源:igfitidea点击:

Eclipse Unresolved compilation

eclipsecompiler-errors

提问by codegirl

I have this really weird problem working on a bigger project in Eclipse Indigo 3.7.2. I checked out the project from an SVN repository using the Subclipse plug-in and when I start the application I get the following error message:

我在 Eclipse Indigo 3.7.2 中处理一个更大的项目时遇到了这个非常奇怪的问题。我使用 Subclipse 插件从 SVN 存储库检出项目,当我启动应用程序时,我收到以下错误消息:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

at anares.preprocess.StanfordParser.getInstance(StanfordParser.java:73)
at anares.start.Startconsole.<init>(Startconsole.java:22)
at anares.start.Startconsole.main(Startconsole.java:52)

This is what Startconsole.class looks like, containing the main method:

这是 Startconsole.class 的样子,包含主要方法:

package anares.start;

import java.io.FileNotFoundException;
import java.io.IOException;

import anares.core.AnaResAlgorithm;
import anares.preprocess.MorphaDornerSentenceSplitter;
import anares.preprocess.CollectionEquipper;
import anares.preprocess.ParserHandlerInterface;
import anares.preprocess.Preprocessor;
import anares.preprocess.SplitterInterface;
import anares.preprocess.StanfordParser;
import anares.text.AnaResTextObject;

public class Startconsole {

public final ParserHandlerInterface parserint = StanfordParser.getInstance();

public final SplitterInterface splitterint = MorphaDornerSentenceSplitter.getInstance();

public final CollectionEquipper equipperint = null;

public final static int buffersize = 5;

private Startconsole(String file) throws IOException {
    AnaResTextObject object = startPreprocess(file);
    startAlgorithm(object);
}

private AnaResTextObject startPreprocess(String file) throws IOException {
    Preprocessor prepro = new Preprocessor(parserint, splitterint,
            equipperint);
    AnaResTextObject textObject = prepro.preprocessText(file);
    return textObject;
}

private void startAlgorithm(AnaResTextObject object) {
    AnaResAlgorithm algo = new AnaResAlgorithm(buffersize);
    algo.resolveAnaphora(object);
}

public static void main(String args[]) throws FileNotFoundException,
        IOException {
    if(args.length > 0){
        Startconsole console = new Startconsole(args[0]);
    }else{
        Startconsole console = new Startconsole("Text.txt");
    }
    }
}

As I was saying this is a bigger project and therefore contains a few .jar-files and references to other packages.
This problem only occurs on my laptop. On my other PC everything works fine, and a fellow student of mine, who works on the same project, does not have any problems either. I already tried checking the project out again, cleaning it up and even reinstalling eclipse.
Now here's the weird part: If I comment out the whole main method, just leaving something like

正如我所说,这是一个更大的项目,因此包含一些 .jar 文件和对其他包的引用。
这个问题只发生在我的笔记本电脑上。在我的另一台电脑上一切正常,我的一个同学在同一个项目上工作,也没有任何问题。我已经尝试再次检查项目,清理它甚至重新安装 eclipse。
现在是奇怪的部分:如果我注释掉整个 main 方法,只留下类似

public static void main(String args[]) throws FileNotFoundException,
        IOException {
//      if(args.length > 0){
//          Startconsole console = new Startconsole(args[0]);
//      }else{
//          Startconsole console = new Startconsole("Text.txt");
//      }
    System.out.println("Hello World!");
}

I still get the exact same error message with the exact same line numbers. And no "Hello World!" in the output.
Does anyone have any ideas where the problem comes from?

我仍然使用完全相同的行号收到完全相同的错误消息。没有“Hello World!” 在输出中。
有没有人知道问题来自哪里?

回答by Zoltán Ujhelyi

Your issue seems like either there is an error in the code that I cannot see, or your Eclipse instance/compiler got into a strange state it cannot recover from.

您的问题似乎是代码中存在我看不到的错误,或者您的 Eclipse 实例/编译器进入了无法恢复的奇怪状态。

Just some basic ideas to check

只是一些基本的想法来检查

  1. Have you tried restarting Eclipse?
  2. Are you using the same version of Java on all computers? E.g. there might be some incompatibilities between Java 6 and Java 7.
  3. Is automatic build turned on? Look in the Project/Build automatically menu item. It is possible that the automatic Java builder got turned off, and thus it does not recompile your code.
  4. Have you tried to clean your project to force a rebuild? (Project/Clean menu item).
  5. Is JDT installed in your Eclipse instance? It should be, but it might worth check for such trivial issue.
  6. Maybe you should try to create a new workspace, and checkout the projects again.
    • You could also try to download Eclipse again with this new workspace idea.
  1. 您是否尝试过重新启动 Eclipse?
  2. 您是否在所有计算机上使用相同版本的 Java?例如,Java 6 和 Java 7 之间可能存在一些不兼容。
  3. 是否开启了自动构建?在 Project/Build automatically 菜单项中查找。自动 Java 构建器可能已关闭,因此它不会重新编译您的代码。
  4. 您是否尝试清理您的项目以强制重建?(项目/清理菜单项)。
  5. 您的 Eclipse 实例中是否安装了 JDT?应该是,但对于这种微不足道的问题可能值得检查。
  6. 也许您应该尝试创建一个新工作区,然后再次签出项目。
    • 您还可以尝试使用这个新的工作区想法再次下载 Eclipse。

If neither of these things work, I have no idea what to look for.

如果这些东西都不起作用,我不知道要寻找什么。

回答by E-Riz

Look in Eclipse's Problemsview (tab); any compilation problems in the project will be reported there. You can double-click on an error or warning in the Problemsview and the editor will open on the specific line that is a problem.

查看 Eclipse 的问题视图(选项卡);项目中的任何编译问题都会在那里报告。您可以双击问题视图中的错误或警告,编辑器将在出现问题的特定行上打开。

回答by Arshad

Do one thing just remove the build path of englischPCFG.ser.gz from your project because i am sure this is not the jar file you have added in your project

做一件事,只需从您的项目中删除 englischPCFG.ser.gz 的构建路径,因为我确定这不是您在项目中添加的 jar 文件