- Download antlr-4.9-complete.jar (or whatever version) from https://www.antlr.org/download/ Save to your directory for 3rd party Java libraries, say
C:\Javalib
- Add
antlr-4.9-complete.jar
to CLASSPATH, either:
- Permanently: Using System Properties dialog > Environment variables > Create or append to
CLASSPATH
variable - Temporarily, at command line:
SET CLASSPATH=.;C:\Javalib\antlr-4.9-complete.jar;%CLASSPATH%
- Create short convenient commands for the ANTLR Tool, and TestRig, using batch files or doskey commands:
- Batch files (in directory in system PATH) antlr4.bat and grun.bat
java org.antlr.v4.Tool %*
@ECHO OFF
SET TEST_CURRENT_DIR=%CLASSPATH:.;=%
if "%TEST_CURRENT_DIR%" == "%CLASSPATH%" ( SET CLASSPATH=.;%CLASSPATH% )
@ECHO ON
java org.antlr.v4.gui.TestRig %*
- Or, use doskey commands:(上面创建bat文件没成,下面的方法可行)
doskey antlr4=java org.antlr.v4.Tool $*
doskey grun =java org.antlr.v4.gui.TestRig $*
Testing the installation
Either launch org.antlr.v4.Tool directly:
$ java org.antlr.v4.Tool
ANTLR Parser Generator Version 4.9
-o ___ specify output directory where all output is generated
-lib ___ specify location of .tokens files
...
or use -jar option on java:
$ java -jar /usr/local/lib/antlr-4.9-complete.jar
ANTLR Parser Generator Version 4.9
-o ___ specify output directory where all output is generated
-lib ___ specify location of .tokens files
...