[antlr-interest] Java doesn't find class definition

mblp at mega.ist.utl.pt mblp at mega.ist.utl.pt
Tue Apr 3 08:55:20 PDT 2007


As for eclipse, all required classes should be on the project's build
path - this includes jars also, as well as a JDK. You must've ment
that eclipse doesn't run the Test class, no?

As for "java Test", that only works if you are in your project's bin
directory (the dir with the .class files), and you do not use jars,
which of course you should use, if you are using antlr.

you should type "java -classpath
path/to/build/dir;path/to/jar1.jar;path/to/jar2.jar;... Test
the java command should know where are the .class files(wheter in a
dir or in a jar) that it should search in order to run things; that's
why you need to pass all referenced jars to classpath parameter.

Do you know the ant tool? http://ant.apache.org/ it really helps to
automate build processes.

Miguel Ping

On 4/3/07, Johannes Luber <jaluber at gmx.de> wrote:
> Hello,
>
> whenever I want to start a test program via "java Test" or similar on
> the command line, java complains: "Exception in thread "main"
> java.lang.NoClassDefFoundError: Test".
>
> I can get the ANTLR tools running and in Eclipse I can start those
> programs, too, but for whatever reason it doesn't work on the command
> line. As Eclipse doesn't compile some projects because it believes that
> a class doesn't have all referenced members, I have to compile those
> files on the command line - without problems. But switching back and
> forth isn't improving my productivity and getting on my nerves. I'm open
> for suggestions how to fix the situation. I'm running Windows XP and the
> following JRE:
>
> "java version "1.6.0"
> Java(TM) SE Runtime Environment (build 1.6.0-b105)
> Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)"
>
> The ANTLR libs are in the classpath which the ANTLR tools can access. So
> I don't believe that the problem lies in there. If additional
> information is required simply ask me.
>
> Thanks in advance,
> Johannes Luber
>


More information about the antlr-interest mailing list