Getting started with JavaCC
Asked Answered
D

6

7

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.

Dariadarian answered 21/7, 2013 at 19:39 Comment(0)
Y
20

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

Yacketyyak answered 22/7, 2013 at 6:0 Comment(0)
F
3

In Windows, I also had no javacc and have to use

java -cp bin\lib\javacc.jar javacc

instead. This is very frustrating because all docs propose to use javacc, which we miss. Yet, I see that javacc was defined in the old javacc 5.0. I see javacc.bat there

java -classpath "%~dp0lib\javacc.jar;%~dp0lib\javacc.jar;%~f0\..\lib\javacc.jar" javacc %1 %2 %3 %4 %5 %6 %7 %8 %9
Foxtail answered 14/4, 2015 at 10:18 Comment(0)
V
2

more javacc:

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

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

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

more jjtree:

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

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

java -classpath "$JAR" jjtree "$@"

Create these scripts in the bin folder of your javacc-6.0/bin.

make a chmod :

chmod 755 javacc
chmod 755 jjtree
Venavenable answered 11/10, 2013 at 20:6 Comment(0)
P
2

On Mac OS X & Linux I just use a single script and two symbolic links:

echo 'java -cp /path/to/javacc.jar $(basename $0) "$@"' > javacc
chmod 755 javacc
ln -s javacc jjtree
ln -s javacc jjdoc

The first two lines create the script and make it executable. The second two lines reuse the javacc script for jjtree and jjdoc, since it all comes from the same JAR.

Planogamete answered 17/8, 2014 at 12:36 Comment(0)
B
0

You need to first unzip the package, and add location where your javacc is located in your PATH environment variable.

like: set path=%path%;<location_of_your_javacc>;

Bricebriceno answered 21/7, 2013 at 19:44 Comment(2)
@AhmedMasud when he posted the question initially he didnt specify which OS he is using, after my answer he edited the question.Bricebriceno
-bash: javacc: command not found was in the original version though. Its not a big deal anyways.Dariadarian
V
0

Check if you have javacc and jjtree in the bin/ directory of your javacc-6.0.zip. When you get javacc6.0 from https://javacc.java.net/, this bin directory is empty.

javacc & jjtree are scripts.

Actually i'm using Java 5.0 and i'm modified my .profile file to add (I put javacc in my Applications folder):

export
PATH=/opt/local/bin:/opt/local/sbin:/Applications/javacc-5.0/bin/:$PATH

It's working perfectly.

Venavenable answered 11/10, 2013 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.