Link to home
Start Free TrialLog in
Avatar of virendra032700
virendra032700

asked on

java.lang.ClassNotFoundException

I am writing a utility for testing DAO classes. called StoredProcTest, in which I wanted to create a connection. I am getting this error, even I am setting the classpath like this,

Classpath settings are,

set CLASSPATH=.;D:\bea\wlserver6.0sp1\lib\weblogic_sp.jar;.D:\bea\wlserver6.0sp1\lib\weblogic-connenv-patch.jar;.D:\bea\wlserver6.0sp1\lib\weblogic.jar;.D:\bea\wlserver6.0sp1\config\mydomain\serverclasses;.D:\bea\wlserver6.0sp1\config\mydomain\lib\log4j.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\jconn2.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\xerces.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\romatcher.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\dummy.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\crypto.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\iaik_jce_full.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\dataconfig.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\chart.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\CWrapper.jar;.D:\bea\wlserver6.0sp1\config\mydomain\lib\messaging.jar


The error after running is like this,

D:\VirendraJava>java StoredProcTest
java.lang.ClassNotFoundException: com.sybase.jdbc2.jdbc.SybDriver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
        at java.lang.ClassLoader.loadClass(Compiled Code)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:275)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:237)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:124)
        at StoredProcTest.main(Compiled Code)
Hello World!

D:\VirendraJava>
Avatar of bobbit31
bobbit31
Flag of United States of America image

which jar file is com.sybase.jdbc2.jdbc.SybDriver in?
you could also try:

java -cp %CLASSPATH% StoredProcTest
Avatar of virendra032700
virendra032700

ASKER

I tried like that, but same error.

Interesting thing is the last System.out.println("Hello World"); is printed as a last statement in exception.
com.sybase.jdbc2.jdbc.SybDriver class is in jconn2.jar.

Could u pl just write the classpath setting only for thius jar.
what does this do:

java -cp D:\bea\wlserver6.0sp1config\mydomain\lib\jconn2.jar StoredProcTest
This is the error I got,

D:\VirendraJava>java -cp D:\destinydocs\jconn2.jar StoredProcTest
Exception in thread "main" java.lang.NoClassDefFoundError: StoredProcTest

D:\VirendraJava>
ASKER CERTIFIED SOLUTION
Avatar of bobbit31
bobbit31
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much, for your help. Could you just elaborate why .\;d:\ was required.
.\ is the current directory (where StoredProcTest is)

did it work?

if so, then something is wrong w/ your classpath in your autoexec.bat (though if that's so, i don't see how you got your code compiled)

also, i noticed that in your classpath you have '.' before most of your paths (ie: .D:\bea\wlserver6.0sp1config\mydomain\lib\jconn2.jar

remove them.
It does work, also I think classpath settings could be wrong.