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\wlserve r6.0sp1\li b\weblogic _sp.jar;.D :\bea\wlse rver6.0sp1 \lib\weblo gic-connen v-patch.ja r;.D:\bea\ wlserver6. 0sp1\lib\w eblogic.ja r;.D:\bea\ wlserver6. 0sp1\confi g\mydomain \servercla sses;.D:\b ea\wlserve r6.0sp1\co nfig\mydom ain\lib\lo g4j.jar;.D :\bea\wlse rver6.0sp1 \config\my domain\lib \jconn2.ja r;.D:\bea\ wlserver6. 0sp1\confi g\mydomain \lib\xerce s.jar;.D:\ bea\wlserv er6.0sp1\c onfig\mydo main\lib\r omatcher.j ar;.D:\bea \wlserver6 .0sp1\conf ig\mydomai n\lib\dumm y.jar;.D:\ bea\wlserv er6.0sp1\c onfig\mydo main\lib\c rypto.jar; .D:\bea\wl server6.0s p1\config\ mydomain\l ib\iaik_jc e_full.jar ;.D:\bea\w lserver6.0 sp1\config \mydomain\ lib\dataco nfig.jar;. D:\bea\wls erver6.0sp 1\config\m ydomain\li b\chart.ja r;.D:\bea\ wlserver6. 0sp1\confi g\mydomain \lib\CWrap per.jar;.D :\bea\wlse rver6.0sp1 \config\my domain\lib \messaging .jar
The error after running is like this,
D:\VirendraJava>java StoredProcTest
java.lang.ClassNotFoundExc eption: com.sybase.jdbc2.jdbc.SybD river
at java.net.URLClassLoader$1. run(URLCla ssLoader.j ava:202)
at java.security.AccessContro ller.doPri vileged(Na tive Method)
at java.net.URLClassLoader.fi ndClass(UR LClassLoad er.java:19 1)
at java.lang.ClassLoader.load Class(Comp iled Code)
at sun.misc.Launcher$AppClass Loader.loa dClass(Lau ncher.java :275)
at java.lang.ClassLoader.load Class(Clas sLoader.ja va:237)
at java.lang.Class.forName0(N ative Method)
at java.lang.Class.forName(Cl ass.java:1 24)
at StoredProcTest.main(Compil ed Code)
Hello World!
D:\VirendraJava>
Classpath settings are,
set CLASSPATH=.;D:\bea\wlserve
The error after running is like this,
D:\VirendraJava>java StoredProcTest
java.lang.ClassNotFoundExc
at java.net.URLClassLoader$1.
at java.security.AccessContro
at java.net.URLClassLoader.fi
at java.lang.ClassLoader.load
at sun.misc.Launcher$AppClass
at java.lang.ClassLoader.load
at java.lang.Class.forName0(N
at java.lang.Class.forName(Cl
at StoredProcTest.main(Compil
Hello World!
D:\VirendraJava>
which jar file is com.sybase.jdbc2.jdbc.SybD river in?
you could also try:
java -cp %CLASSPATH% StoredProcTest
java -cp %CLASSPATH% StoredProcTest
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.
Interesting thing is the last System.out.println("Hello World"); is printed as a last statement in exception.
ASKER
com.sybase.jdbc2.jdbc.SybD river class is in jconn2.jar.
Could u pl just write the classpath setting only for thius jar.
Could u pl just write the classpath setting only for thius jar.
what does this do:
java -cp D:\bea\wlserver6.0sp1confi g\mydomain \lib\jconn 2.jar StoredProcTest
java -cp D:\bea\wlserver6.0sp1confi
ASKER
This is the error I got,
D:\VirendraJava>java -cp D:\destinydocs\jconn2.jar StoredProcTest
Exception in thread "main" java.lang.NoClassDefFoundE rror: StoredProcTest
D:\VirendraJava>
D:\VirendraJava>java -cp D:\destinydocs\jconn2.jar StoredProcTest
Exception in thread "main" java.lang.NoClassDefFoundE
D:\VirendraJava>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.0sp1conf ig\mydomai n\lib\jcon n2.jar
remove them.
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.0sp1conf
remove them.
ASKER
It does work, also I think classpath settings could be wrong.