- The version I use is 4.9.2 , on Windows10 and Ubuntu16.04
- I used java8 provided in g4
- This is my test code
Test2.java:
class mytest {
public void hello() {
System.out.println("hello1");
}
public void hello2() {
System.out.println("hello2");
hello();
}
}
public class Test2 {
public static void main(final String[] args) throws Exception {
mytest a = new mytest();
a.hello();
a.hello2();
System.out.println("hello3");
}
}
- I can guarantee that this is the correct code and it can run.
- I do this first
java -jar D:\lib\antlr\antlr-4.9.2-complete.jar Java8Lexer.g4
java -jar D:\lib\antlr\antlr-4.9.2-complete.jar Java8Parser.g4
- Then I compile them
javac -cp ".;D:\lib\antlr\antlr-4.9.2-complete.jar" Java*.java
- None of the above errors
- I want to get a tree,so I
javac Test2.java
java -cp ".;D:\lib\antlr\antlr-4.9.2-complete.jar" org.antlr.v4.gui.TestRig Test2 r -tree
- But no matter how I try, I get this result
Exception in thread "main" java.lang.ClassCastException: class Test2
at java.lang.Class.asSubclass(Class.java:3404)
at org.antlr.v4.gui.TestRig.process(TestRig.java:135)
at org.antlr.v4.gui.TestRig.main(TestRig.java:119)
- I have tried various methods on the Internet but no solution.I also tried it on Ubuntu 16.04, and the same result.
- plz help me TT