错误:无法找到或加载主类org.antlr.Tool

时间:2013-03-18 17:33:50

标签: java build ubuntu-12.04 netbeans-7 antlr3

我是java和ANTLR的初学者。 我想在Netbeans IDE中使用ANTLR。 我试图运行一个示例示例,并按照所需的所有重要步骤进行操作,例如设置环境变量,包括jar文件和修改built.xml。

但是当我尝试清理并构建我的应用程序时,我会遇到以下错误:

Error: Could not find or load main class org.antlr.Tool

Java Result: 1
Created dir: ../NetBeansProjects/AntlrTestApp/build/empty
Created dir: ../NetBeansProjects/AntlrTestApp/build/generated-sources/ap-source-output

Compiling 1 source file to ../NetBeansProjects/AntlrTestApp/build/classes
../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:24: error: cannot find symbol
    grammarLexer lexer = new grammarLexer(input);
  symbol:   class grammarLexer
  location: class AntlrTestApp

../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:24: error: cannot find symbol
    grammarLexer lexer = new grammarLexer(input);
  symbol:   class grammarLexer
  location: class AntlrTestApp

../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:26: error: cannot find symbol
    grammarParser parser = new grammarParser(tokens);
  symbol:   class grammarParser
  location: class AntlrTestApp

../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:26: error: cannot find symbol
    grammarParser parser = new grammarParser(tokens);
  symbol:   class grammarParser
  location: class AntlrTestApp

../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:29: error: cannot find symbol
    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  symbol:   class Main
  location: class AntlrTestApp

../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:31: error: cannot find symbol
    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  symbol:   class Main
  location: class AntlrTestApp

6 errors

../NetBeansProjects/AntlrTestApp/nbproject/build-impl.xml:603: The following error occurred while executing this line:

../NetBeansProjects/AntlrTestApp/nbproject/build-impl.xml:244: Compile failed; see the compiler error output for details.

BUILD FAILED (total time: 1 second)

自从过去2-3天以来,我一直在努力寻找所有可能的解决方案,但对我来说没有任何效果。

2 个答案:

答案 0 :(得分:2)

看起来你正在尝试在Ant构建期间从ANTLR 3语法自动生成解析器。以下Ant脚本显示了此示例,其中包括以下功能:

  • 必要时自动下载必要的ANTLR 3工具版本,这样您就不必将文件包含在源代码管理中或手动设置构建机器。
  • 自动查找指定源文件夹中的所有.g个文件,因此每次添加语法时都不必编辑构建。
  • 完全处理最新的检查以获得最大的增量构建性能。

https://github.com/antlr/antlr4/blob/master/build.xml

答案 1 :(得分:0)

我有类似的错误。使用antlr-x-complete.jar发布解决了我的问题。