Getting started with JavaCC

I am new to JavaCC and cannot figure out how to run it. I am using Mac OS X and I installed javacc-6.0.zip and unzipped it. I can not make javacc script accessible from my path, because when I type javacc on the terminal, I get the following message:

  -bash: javacc: command not found 

How to make javacc script available from my path?

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

So, I am doing the following on the terminal:

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

Entering javacc next gives me the same message.

+6
source share
6 answers

The version of JavaCC 6.0 downloaded today (2013.07.22) did not have a complete bin directory. There were no script files in it! Hope this will be fixed soon.

For OS X and other variants of unix / linux, the missing script file is called javacc, it must be executable, and must 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 (excluding the backslash - as pointed out by Ahmed Masood), and everything should be a ticket. 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 bin bin directory.

+13
source

On Mac OS X and Linux, I just use one 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 a script and make it executable. The second two lines reuse the javacc script for jjtree and jjdoc, since all this comes from the same JAR.

+2
source

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 .

do chmod:

 chmod 755 javacc chmod 755 jjtree 
+1
source

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

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

0
source

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 and jjtree are scripts.

I actually use Java 5.0, and I modified my .profile file to add (I put javacc in the My Applications folder):

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

It works great.

0
source

On Windows, I also did not have javacc and need to use

 java -cp bin\lib\javacc.jar javacc 

instead of this. This is very unpleasant, because all the documents suggest using javacc , which we skip. However, I see that javacc was defined in 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 
0
source

Source: https://habr.com/ru/post/949944/


All Articles