Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am a beginner in both java and ANTLR. I am trying to use ANTLR in Netbeans IDE. I was trying to run a sample example and did follow all the important steps required like setting the environment variable, including jar file and modifying built.xml.

But when I try to clean and build my application I get following errors:

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)

I have been trying this since last 2-3 days and searched for all possible solutions but nothing worked for me.

like image 433
user134816 Avatar asked Nov 04 '22 02:11

user134816


1 Answers

It looks like you're trying to automatically generate a parser from an ANTLR 3 grammar during an Ant build. The following Ant script shows an example of this that includes the following features:

  • Automatically downloads the necessary version of the ANTLR 3 tool when necessary, so you don't have to include the file in source control or manually set up your build machines.
  • Automatically locates all .g files in the specified source folders, so you don't have to edit the build every time you add a grammar.
  • Complete handling of up-to-date checks for maximum incremental build performance.

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

like image 79
Sam Harwell Avatar answered Nov 14 '22 22:11

Sam Harwell