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
Solved

java.lang.ClassNotFoundException

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

 

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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
reverse digits of a number using for loop 5 52
Java Restore security prompts not working 10 56
Fast way to search item into Java Array (Rhino compatible) 2 31
jsp error 6 25
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

856 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