macosterminalinstallationjavacc

Installing javacc on mac with terminal


I have downloaded javacc-5.0 and tried to follow various different guides to no avail.

I unzipped the package, modified the PATH variable to contain ../javacc-5.0/bin/lib/javacc.jar directory and ensured that all the correct files are executable. However, a which javacc command gives no output and trying to run the javacc exec has also given the error Could not find or load main class javacc (the jar file is definitely there in the lib directory).


Solution

  • In the ...../javacc-5.0/bin directory, there should be a file called javacc that should looks something like this

    #!/bin/sh
    JAR="`dirname $0`/lib/javacc.jar"
    
    case "`uname`" in
         CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
    esac
    
    java -classpath "$JAR" javacc "$@"
    

    If so, edit your PATH variable to include /....../javacc-5.0/bin, i.e. the absolute path of that bin directory. There is no need for the PATH variable to include /....../javacc-5.0/bin/lib/javacc.jar; so take that out.

    Start a new terminal. In the new terminal, check the PATH variable with echo $PATH. Try which javacc. Try javacc.