Getting started with JavaCC

Rishabh Garg picture Rishabh Garg · Jul 21, 2013 · Viewed 8k times · Source

I am new to JavaCC and cannot figure out how to get it running. I am using Mac OS X and I installed javacc-6.0.zip and unzipped it. I am unable to make the javacc script accessible from my path as on typing javacc on the terminal I get the following message:

    -bash: javacc: command not found

How do I make the javacc script accessible from my path?

My unzipped folder javacc-6.0 is in the following directory: /Users/Rishabh/Desktop/javacc

So I do the following on the terminal:

    PATH=$PATH\:/Users/Rishabh/Desktop/javacc/javacc-6.0/

Typing javacc next gives me the same message.

Answer

Theodore Norvell picture Theodore Norvell · Jul 22, 2013

The version of JavaCC 6.0 that I downloaded today (2013.07.22) did not have a complete bin directory. It was missing all the script files! Hopefully this will be remedied soon.

For OS X and other unix/linux variants, the missing script file is called javacc, should be executable, and should contain the following:

#!/bin/sh
JAR="`dirname $0`/lib/javacc.jar"

case "`uname`" in
     CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
esac

java -classpath "$JAR" javacc "$@"

Add the bin directory to your PATH (omitting the backslash -- as pointed out by Ahmed Masud) and all should be ticketty boo. If your OS comes from Redmond or you want to run jjtree or jjdoc, just download javacc-5.0 and copy the script files (NOT the lib directory!!!!) from the 5.0 bin directory to the 6.0 bin directory.


Update (2020): Since version 6 is now harder to find, I have put a copy at www.engr.mun.ca/~theo/JavaCC/javacc-6.1.0.zip