• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Problem setting Driver in Classpath

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,I am having trouble setting the classpath for my Driver class. I have a simple database program that registers a driver class org.postgresql.Driver in the function - Class.forname().The class file is defined in a jar file pgdev.307.jdbc3.jar, which is in the directory c:\postgre.
On Extracting the jar file, I get the following directory structure:
C:\postgre\org\postgresql\Driver.class

I have tried to set the classpath as:
set classpath=C:\postgre\pgdev.307.jdbc3.jar
but on running the program, I get :
java.lang.ClassNotFoundException rg.postgresql.Driver

Can someone please help me with the problem.

[edited to disable smilies]
[ November 02, 2004: Message edited by: Jeanne Boyarsky ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you running a stand-alone allication or in an application server or some other configuration?

I ask since app servers ignore the classpath so you could set it to whatever you wanted and it wouldn't make a difference to the server!

If you're in a servlet container, it's typically best to drop your jar in the WEB-INF/lib directory. The container will then find and load the jar file contents for you.

If you're using a stand-alone application, try using the javap command to test your classpath. ie type javap org.postgresql.Driver and see if it works. You can then play with your classpath to get it right without having to worry about your code.
 
author & internet detective
Posts: 40746
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Madhur,
I'm assuming you are not using an application server. (If you are, you should be using datasources, not Class.forName().)

Are you setting the classpath as an environment variable or a command line argument? Try using the -classpath switch while debugging. That will guarantee things are set the way you want.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic