[antlr-interest] Problem running book examples

Andreas Kumlehn kumlehna at upb.de
Tue Jun 8 07:44:29 PDT 2010

Hi all, 
I want to develop a configuration file for some tool of mine and 
therefore decided to dive into ANTLR. The definitive ANTLR reference 
book arrived some days ago and I tried some of the examples from the book's website. 

To generate the lexer/parser and compiling the Java files the 
following commands work without erros: 
java -cp ./lib/antlr-3.1.3.jar:./lib/antlr-2.7.7.jar:./lib/ 
stringtemplate-3.2.jar org.antlr.Tool Expr.g 
javac -cp ./lib/antlr-3.1.3.jar:./lib/antlr-2.7.7.jar:./lib/ 
stringtemplate-3.2.jar ExprLexer.java ExprParser.java Test.java 

When I try to run the provided testrig coded in Test.java with command 
java -cp ./lib/antlr-3.1.3.jar:./lib/antlr-2.7.7.jar:./lib/ 
stringtemplate-3.2.jar Test 
results in the following error: 

Exception in thread "main" java.lang.NoClassDefFoundError: Test 
Caused by: java.lang.ClassNotFoundException: Test 
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
        at java.security.AccessController.doPrivileged(Native Method) 
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307) 
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248) 

The commands above are from my Mac, but I tried this on a WinXP 
machine, too (with adapted paths).

Current SDK is installed, everything else works fine. Any suggestions or hints?
Thanks for helping! 

More information about the antlr-interest mailing list