1

I am not sure why but I am getting error when trying to run my java file in cmd using javac MyCompiler.java. The file runs fine when I run it from Intellij. I have already added C:\Program Files\Java\jdk1.8.0_144\bin to class path.

The error I am getting:

MyCompiler.java:4: error: package org.antlr.v4.gui does not exist
import org.antlr.v4.gui.TreeViewer;
                   ^
MyCompiler.java:5: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.*;
^
MyCompiler.java:6: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.*;
^
.\CompilerBaseVisitor.java:2: error: package org.antlr.v4.runtime.tree does 
not exist
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
                            ^
.\CompilerBaseVisitor.java:12: error: cannot find symbol
public class CompilerBaseVisitor<T> extends AbstractParseTreeVisitor<T> 
implements CompilerVisitor<T> {
                                        ^
symbol: class AbstractParseTreeVisitor
.\CompilerVisitor.java:2: error: package org.antlr.v4.runtime.tree does not 
exist
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
                            ^
.\CompilerVisitor.java:11: error: cannot find symbol
public interface CompilerVisitor<T> extends ParseTreeVisitor<T> {
                                        ^
symbol: class ParseTreeVisitor
.\CompilerParser.java:2: error: package org.antlr.v4.runtime.atn does not 
exist
import org.antlr.v4.runtime.atn.*;
^
.\CompilerParser.java:3: error: package org.antlr.v4.runtime.dfa does not 
exist
import org.antlr.v4.runtime.dfa.DFA;
                           ^
.\CompilerParser.java:4: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.*;
^
.\CompilerParser.java:5: error: package org.antlr.v4.runtime.misc does not 
exist
import org.antlr.v4.runtime.misc.*;
^
.\CompilerParser.java:6: error: package org.antlr.v4.runtime.tree does not 
exist
import org.antlr.v4.runtime.tree.*;

The error seems to be ANTLR related but I am not sure how to fix it. Any help will be appreciated.

AaySquare
  • 123
  • 10
  • 2
    Your `javac` call doesn't appear to have anything to include antlr jar files in the classpath. Hopefully that's enough of a hint for you to research further. – Jon Skeet Mar 21 '18 at 20:31
  • See https://github.com/antlr/antlr4/blob/master/doc/getting-started.md for an example of how to run the generated file – Ruan Mendes Mar 21 '18 at 20:39

0 Answers0