1
public class GrammarValidityTest {
  private String[] dataPaths = new String[] {"data/", "freebase/", "tables/", "regex/"};

  @Test(groups = {"grammar"})
  public void readGrammars() {
    try {
      List<String> successes = new ArrayList<>(), failures = new ArrayList<>();
      for (String dataPath : dataPaths) {
   // Files.walk(Paths.get(dataPath)).forEach(filePath -> { 
      try {
        if (filePath.toString().toLowerCase().endsWith(".grammar")) {
          Grammar test = new Grammar();
          LogInfo.logs("Reading grammar file: %s", filePath.toString());
          test.read(filePath.toString());
          LogInfo.logs("Finished reading", filePath.toString());
          successes.add(filePath.toString());
        }
      }
      catch (Exception ex) {
        failures.add(filePath.toString());
      }
    });
  }
  LogInfo.begin_track("Following grammar tests passed:");
  for (String path : successes)
    LogInfo.logs("%s", path);
  LogInfo.end_track();
  LogInfo.begin_track("Following grammar tests failed:");
  for (String path : failures)
    LogInfo.logs("%s", path);
  LogInfo.end_track();
  assertEquals(0, failures.size());
}
catch (Exception ex) {
  LogInfo.logs(ex.toString());
}
}
}

The line beginning with // is the one that brings up the error -"illegal start of expression" starting at the '>' sign. I do not program much in java. I just downloaded a code from somewhere that is quite popular and supposed to run but I got this error. Any help/fixes/explanation would be appreciated.

1 Answer 1

2

Run javac -version and verify that you are actually using the compiler from JDK8, it's possible that even if your java points to the 1.8 releaase, your javac has a different version.

If you are using Eclipse, remember to set the source type for your project to 1.8.

Edit:

Since you are using ant, verify that your JAVA_HOME environment variable points to your jdk1.8 directory.

Sign up to request clarification or add additional context in comments.

1 Comment

javac -version returns javac 1.8.0_45 I am using terminal. I did get it using ant

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.