Solved

java.lang.ClassNotFoundException

Posted on 2002-04-12
10
1,152 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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 100 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
factorial example challenge 10 62
json format text only 4 65
word0 challenge 4 53
Core Java. What output will be and why ? 6 58
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now