Could not load main class in JavaCC

时光毁灭记忆、已成空白 提交于 2019-12-11 02:46:09

问题


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


回答1:


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.




回答2:


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

...



来源:https://stackoverflow.com/questions/19867328/could-not-load-main-class-in-javacc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!