Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime JDBC NoClassDefFoundError

Status
Not open for further replies.

sjpatrick

Programmer
Sep 4, 2001
54
US
At my wits' end here...

I'm certain six ways from Sunday that my classpath is correct, so please resist telling me that's my problem.

I started by getting this error using MySql Connector, and have progressed to even trying a brand new install of postgres, but continue to get this selfsame error:

Exception in thread "main" java.loang.NoClassDefFoundError: HelloJava

Only at runtime; compiles clean as a whistle.

Anybody got a silver bullet? :)
 
You're not going to like it ...

Its your CLASSPATH . 100% .

There are three possibilities that I know of for causing a NoClassDefFoundError :

1) The class is not on the CLASSPATH

2) There is a naming conflict on the CLASSPATH - ie two classes named "Whatever.class" exist - and the ClassLoader barfs trying to load them

3) A native/JNI based resource that your class, or another class used by your class, is required, but that native resource is not in the PATH, or LD_LIBRARY_PATH .

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Just because your *.java code is in the path, doesn't mean your final *.class file is. I was once using some software to compile my code. It did the job, but I couldn't control where it was putting the *.class file. I'd have to go get it and move it everytime I used this! Needless to say, I don't use that software for compiling code anymore!

Anyway, double-check that your *.class file is where it needs to be.

I'm not exactly telling you to check your classpath!

'hope that helps.

--Dave
 
Okay, sedj.

You win. :)

I went back to a dumb hello program and I get the same error.

I'm running jdk5_02 on linux; any clues as to what I'm forgetting to put in my classpath?
 
Say your Hello.class is in /usr/local/java , then you need to set your CLASSPATH thus :

export CLASSPATH=$CLASSPATH:/usr/local/java

Then it should be fine.

Don't forget that many Linux distros come with GNU's Java installed - not Sun's - so you should check that the Sun version of the JRE is being picked up - type "java -version" to determine this.



--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I am officially a moron.

The "silver bullet" is as such:

Separate the assorted values in your classpath statement with COLONS, not semicolons!

(blushing and how...)

Thanks for the help, sedj; I would never have found this if you hadn't forced me to look harder.
 
lol, too much DOS/Win32 time sounds like !

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Unfortunately. :p

Went all the way back to mysql jdbc and it works like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top