Installing ANTLR

Posts: 312
Joined: 2006.10
Post: #1
How do you install ANTLR?

These are the steps I took:

1.) Downloaded ANTLR 3.0.1
2.) Unarchive it, copy it into /usr/local
3.) Add it to my class path by opening ~/.bash_profile with textmate, and appending:

export CLASSPATH="/usr/local/antlr/lib/antlr-3.0.1.jar"
export CLASSPATH="$CLASSPATH:/usr/local/antlr/lib/antlr-2.7.7.jar"
export CLASSPATH="$CLASSPATH:/usr/local/antlr/lib/antlr-runtime-3.0.1.jar"
export CLASSPATH="$CLASSPATH:/usr/local/antlr/lib/stringtemplate-3.1b1.jar"

Now, when I try to run it on commandline:
java org.antlr.Tool MyGrammer.g
Terminal spits this back at me:
va org.antlr.Tool Shader.g
Exception in thread "main" java.lang.NoClassDefFoundError: org/antlr/stringtemplate/StringTemplateErrorListener
    at org.antlr.Tool.main(
Which I googled, and it means that I haven't added antlr to my class path...

What do I need to do to add it to my class path?
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
I've never installed it, always just run it from the download directory...

First, make sure you get "ANTLR 3.0.1 source distribution" (antlr-3.0.1.tar.gz) since it includes all the language runtimes.

Then you can run like this:
cd antlr-3.0.1
java -cp `ls lib/*.jar | tr '\n' ':'` org.antlr.Tool <Grammar FIle>

Dunno what you have to do to "install" it, but that at least appears to work.
Quote this message in a reply
Posts: 312
Joined: 2006.10
Post: #3
thanks, I'll use that for now Smile
Quote this message in a reply
Post Reply