Antlr安装 antlr4.bat和grun.bat不起作用解决

  1. 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
  2. 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%
  1. 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
...
上一篇:45 如何在Linux下查看和切换shell


下一篇:Linux下获取当前进程的执行文件的绝对路径和所在目录(通过/proc/self/exe链接)