[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

java.lang.ClassNotFoundException

Posted on 2002-04-12
10
Medium Priority
?
1,199 Views
Last Modified: 2010-08-05
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>
0
Comment
Question by:virendra032700
  • 5
  • 5
10 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 6936847
which jar file is com.sybase.jdbc2.jdbc.SybDriver in?
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6936866
you could also try:

java -cp %CLASSPATH% StoredProcTest
0
 

Author Comment

by:virendra032700
ID: 6936886
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:virendra032700
ID: 6936961
com.sybase.jdbc2.jdbc.SybDriver class is in jconn2.jar.

Could u pl just write the classpath setting only for thius jar.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6936976
what does this do:

java -cp D:\bea\wlserver6.0sp1config\mydomain\lib\jconn2.jar StoredProcTest
0
 

Author Comment

by:virendra032700
ID: 6936999
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>
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 400 total points
ID: 6937024
ok, try this:

java -cp .\;D:\destinydocs\jconn2.jar StoredProcTest
0
 

Author Comment

by:virendra032700
ID: 6937031
Thank you very much, for your help. Could you just elaborate why .\;d:\ was required.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6937042
.\ 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.
0
 

Author Comment

by:virendra032700
ID: 6937060
It does work, also I think classpath settings could be wrong.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question