Error: Could not find or load main class org.antlr.v4.Tool Antrl4
Asked Answered
S

1

12

I want to use Antlr to create parser and i followed instruction from

Here

after following all instruction while I am running following command antlr4 -visitor D:\T\arithmetic.g4 I am getting this error msg: Error: Could not find or load main class org.antlr.v4.Tool

using this jar file : C:\Program Files\Java\lib\antlr-4.6-complete.jar

Sungkiang answered 5/8, 2017 at 7:32 Comment(2)
What operating system are you using?Omit
@Omit I am using windows 10.Sungkiang
O
12

Your CLASSPATH environment variable isn't set properly. One very good tutorial on setting up ANTLR4 is here. This includes instructions for Windows and Unix-based environments.

Omit answered 5/8, 2017 at 10:12 Comment(7)
I have also used the same link but still not workingSungkiang
Thanks you were right it is due to CLASSPATH. but somehow I am not able to fix it so instead of setting it permanently I using the command prompt to set it for a specific session using the following command: SET CLASSPATH=.;D:\g4Files\antlr-4.7-complete.jar;%CLASSPATH%Sungkiang
Thanks you were right it is due to CLASSPATH. but somehow I am not able to fix it so instead of setting it permanently I using the command prompt to set it for a specific session using the following command: SET CLASSPATH=.;D:\g4Files\antlr-4.7-complete.jar;%CLASSPATH%Sungkiang
@Sungkiang There you go. That is the brute-force approach, but that works too. Well done!Omit
I have the same error and I had to solve with the brute-force way. Someone could install instructions from official guide github.com/antlr/antlr4/blob/master/doc/getting-started.md ?Verbenia
The tutorial has moved. It's now here : tomassetti.me/antlr-mega-tutorial My problem was different and really dumb. I had set CLASSPATH to the folder containing the jar file, not to jar file itself.Communard
@Communard Thank you for the updated link! I've edited the answer to reflect the new location.Omit

© 2022 - 2024 — McMap. All rights reserved.