I got this error message have been browsing for a long time and still couldn't find the reason or the fix for it.
Here is the Error message I am getting:
Error: Unable to initialize main class app.ExpressionApp Caused by: java.lang.NoClassDefFoundError: org/antlr/v4/runtime/tree/ParseTree
Here is the image of my directories (the folder I am trying to run is the visitor one):
And here is the ExpressionApp class content
package app;
import java.io.IOException;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.*;
import Expression.AntlrToProgram;
import Expression.ExpressionProcessor;
import Expression.Program;
import antlr.ExprLexer;
import antlr.ExprParser;
public class ExpressionApp {
public static void main(String[] args) {
if(args.length != 1) {
System.err.print("Usage: file name");
}
else {
String fileName = args[0];
ExprParser parser = getParser(fileName);
ParseTree antlrAST = parser.prog();
AntlrToProgram progVisitor = new AntlrToProgram();
Program prog = progVisitor.visit(antlrAST);
if(progVisitor.semanticErrors.isEmpty()) {
ExpressionProcessor ep = new ExpressionProcessor(prog.expressions);
for(String evaluation: ep.getEvaluationResults()) {
System.out.println(evaluation);
}
}
else {
for(String err: progVisitor.semanticErrors) {
System.out.println(err);
}
}
}
}
private static ExprParser getParser(String fileName) {
ExprParser parser = null;
try {
CharStream input = CharStreams.fromFileName(fileName);
ExprLexer lexer = new ExprLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
parser = new ExprParser(tokens);
} catch (IOException e) {
e.printStackTrace();
}
return parser;
}
}
I have checked whether I have imported any wrong antlr files and nothing was foud