/
How do I install this damn thing?
How do I install this damn thing?
Packages of ANTLR available from the repositories of distributions like Ubuntu are quite old and probably worth avoiding.
Getting a proper Java virtual machine running
You can skip this step if you know Java is properly installed.
- Install a compatible Java virtual machine.
- On Ubuntu or Debian Linux, you can install OpenJDK from the package manager:
sudo apt-get install default-jdk
- On other platforms, use either the Oracle/Sun distribution or OpenJDK.
- On Ubuntu or Debian Linux, you can install OpenJDK from the package manager:
- Check that your Java installation is working:
java -version
Expect output like the following (for OpenJDK on Ubuntu):
java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1~10.04.1) OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
Installing ANTLR
- Visit the download page and download the "Complete ANTLR x.y Java binaries jar" file.
- For example, from a Linux shell, download ANTLR 3.3 to your home directory:
cd ~ wget http://www.antlr.org/download/antlr-3.3-complete.jar
- For example, from a Linux shell, download ANTLR 3.3 to your home directory:
- Add ANTLR to your
CLASSPATH
environmental variable and run it:export CLASSPATH=~/antlr-3.3-complete.jar:$CLASSPATH java org.antlr.Tool -version
Expect output like the following:
ANTLR Parser Generator Version 3.3 Nov 30, 2010 12:50:56
If you see output like the following, the
CLASSPATH
is not set up properly:Exception in thread "main" java.lang.NoClassDefFoundError
If you see an older version of ANTLR, your
CLASSPATH
may not be set up properly and Java may be finding ANTLR in.jar
files bundled with an application like BEA WebLogic. Ensure the path to the current.jar
of ANTLR is at the beginning of yourCLASSPATH
. - Configure your
CLASSPATH
to include ANTLR on future logins.- For example, on a
BASH
shell, add the environmental variable to the.bashrc
script:echo "export CLASSPATH=~/antlr-3.3-complete.jar:$CLASSPATH" >> ~/.bashrc
- For example, on a
, multiple selections available,
Related content
FAQ - Getting Started
FAQ - Getting Started
Read with this
How do I use ant with ANTLR 3?
How do I use ant with ANTLR 3?
Read with this
How do I use ANTLR v3 generated Lexer and Parser from Java?
How do I use ANTLR v3 generated Lexer and Parser from Java?
Read with this
How do I use ANTLR v3 from the command line?
How do I use ANTLR v3 from the command line?
Read with this
FAQ - C Target
FAQ - C Target
Read with this
Five minute introduction to ANTLR 3
Five minute introduction to ANTLR 3
Read with this