I am running a java program in command prompt. I have set the “C:\j2sdk1.4.2_09\bin” in PATH System variable.Then I am able to compile and run the program.But as I need to set the mysql-connector I have set this in “C:\mysql-connector-java-5.1.10\mysql-connector-java-5.1.5-bin.jar”
CLASSPATH variable but now I am able to compile the program as I run the program I get “Exception in thread main java.lang.NoClassFoundDefError”.
How is this? Can anybody elaborate on this?
I am running a java program in command prompt. I have set the C:\j2sdk1.4.2_09\bin
Share
It’s fairly unclear what you’re asking here. Are you saying you changed your CLASSPATH and now the class can’t be found?
One thing to keep in mind is that the CLASSPATH does not, by default, include the current directory. You have to add it (
.) if you want it in the CLASSPATH, e.g.:(Note I put a
.;at the beginning of that.)PATH and CLASSPATH are completely unrelated. PATH tells Windows where to find executable programs (and does implicitly include the current directory) when you run them without giving it an explicit path. CLASSPATH tells the Java runtime where it can load classes from.
Apologies if this is completely off-base; if so, could you clarify your question?