Question

I am AI student and we work with JavaCC. I am new with it. I was trying simple example and I had some errors.

1) I downloaded JavaCC 0.6 from it's website

2) I extracted it in disc C

3) I wrote this code in a file with extension ".jj"

PARSE_BEGIN(Test)

import java.io.*;
class Test
{
    public static void main(string [] args)
    {
        new Test(new InputStreamReader(System.in));
    start();
    }
}
PARSE_END(Test);
Token:
{
    <number: (["0"-"9"])+("." (["0"-"9"])+)?(("e"|"E")(["0"-"9"])+)?>|
    <plus: "+">    
}

void start():
{ }
{
    <number>(<plus><number>)*
}

4) I saved it and put it in javacc/bin folder

5) I wrote this line in command

..."my Path"..javacc Test.jj

6) I had this error

Could not find or load main class javacc

Is there something I have to install before these steps? thx in advance

Was it helpful?

Solution

Use version 5 at https://java.net/projects/javacc/downloads . Version 6.0 is missing the scripts to run JavaCC. If you really want to use version 6.0 you can find the appropriate scripts in version 5, just copy them to version 6's bin directory and away you go.


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

OTHER TIPS

I selected the step you missed in bold below.

The download should have placed into your file system either a ZIP or GZIP file containing the JavaCC software. You should go to the directory where the archive was installed and unzip it's contents. That completes your installation.

Once you have completed installation, add the bin directory within the JavaCC installation to your path. The javacc, jjtree, and jjdoc invocation scripts/executables reside in this directory.

You need to modify PATH system variable in windows (wild guess on used OS). For example as described in

http://www.computerhope.com/issues/ch000549.htm

http://www.java.com/en/download/help/path.xml

...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top