Eclipse Unresolved compilation

2019-08-29 11:08发布

问题:

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:

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:

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

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?

回答1:

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.

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.

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



回答2:

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



回答3:

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