• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassNotFoundException while executing using "java -jar" command

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I developed a java application.
My application connects to postgresql using a database driver(pg73jdbc2.jar).
The database driver jar file is there in my classpath.
My program worked as expected when I executed it using the command

java a.b.c.MyMainClass

Then I bundled my application in to a jar file.
When I tried to execute my program using the command,
java -jar MyJar.jar
it is complaining that the database Driver class(java.lang.ClassNotFoundException: org.postgresql.Driver) is not found.

I am sure that the driver jar is available in my class path and the program is working fine
when a execute it using "java a.b.c.MyMainClass" command

I also tried by copying the driver jar to my "jre/lib/ext" directory, but no luck

What could be the problem ?

Any help would be highly appreciated.

Shahabas E Shabeer
[ June 28, 2005: Message edited by: shahabas shabeer ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jar files are 'closed.' When you use the "-jar" option, the CLASSPATH (or the -cp switch) is ignored. Putting the driver in the /ext directory ought to work, though; or you can use

java -cp MyJar.jar;pg73jdbc2.jar a.b.c.MyMainClass
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
is it possible to add class files to ext folder?
thanks
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic