Solved

java.lang.ClassNotFoundException

Posted on 2002-04-12
10
1,161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
arguments to jar 5 40
How do I remove an object from a 3 53
JAVA API design with micro service cloud in mind 1 82
Where to place postgres JDBC driver jar on tomcat 8 31
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

730 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