That class is not on your classpath.
[url=http://wiki.java.net/bin/view/Javapedia/ClassPath]Javapedia: Classpath[/url]
[url=http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html]Setting the class path[/url] (Windows)
[url=http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html]How Classes are Found[/url]
java -cp .;<any other directories or jars> YourClassName
You get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
javac -classpath .;<any additional jar files or directories> YourClassName.java
You get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
> I used the java -cp . classname, but i still had the
> error. i did not think it was about that. I thought
Just "java -cp . classname" is not enough. You must include the JDBC driver in the classpath. With the statement above you are only putting the current directory in the classpath.
And yes, ClassNotFoundException is ALWAYS a classpath problem.
I thank you for that. but, I am little bit confused about the classpath thing, jdbc, and jar file.For example, everytime I run a program, do I have to set the classpath specific for that program, like the jar file you mentioned? or I set the classpath one time? in this case, could you exactly tell me how to set the classpath for jdbc, jar file? also, if I have to set the classpath onetime, could you tell how?
> I thank you for that. but, I am little bit confused
> about the classpath thing, jdbc, and jar file.For
> example, everytime I run a program, do I have to set
> the classpath specific for that program, like the jar
> file you mentioned? or I set the classpath one time?
You can set the CLASSPATH environment variable to make it permanent, but that's not a good idea for a couple of reasons:
* Not all runtime environments even look at that. IDEs and app servers don't use it, or don't use it the way you might expect.
* Not all your java apps will need the same classpath.
So it's better to provide it each time on the command line. You can use batch files or shell scripts to save you some typing though.
> in this case, could you exactly tell me how to set
> the classpath for jdbc, jar file?
So you didn't really read reply 1 carefully, or the links it contains.
> >just "java -cp . classname" is not enough. You must
> > include the JDBC driver in the classpath. With the
> > statement above you are only putting the current
> > directory in the classpath.
>
> How?
So you didn't really read reply 1 carefully, or the links it contains.
> > >just "java -cp . classname" is not enough. You
> must
> > > include the JDBC driver in the classpath. With
> the
> > > statement above you are only putting the current
> > > directory in the classpath.
well, this time I put the second statement, and I am still having the error.
java -cp . classname; C:\sun\appserver\pointbase\lib\pbclient
or
c:\ set CLASSPATH= classname;pbclient, then run the classfile on the current directory where the classfile is.