Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems loading the driver within a jar

 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Want to load a DB2 Driver within an executable jarfile. The following statements all work if not jared, but don't if they are to be executed within a jar (ClassNotFoundException):




What's the solution to this? Do I need a special ClassLoader for the jar?

Kind regards,
Andy
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not how Jar files work. You can't package Jars inside Jars. Try shipping the driver with your Jar file not in it.

(NB: if this is the DB2 driver you are probably breaking its licence - from memory I don't think you can distribute it).
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, I didn't express myself correctly.
The jarfile, where the driver is located, is outside my jar of course. However the Java statement, which is to load the driver is inside my jar.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you'll need a Class-Path instruction in your Jar file.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... isn't it already sufficient to invoke my jar (ts.jar) with -cp option where the classpath is specified?
All the libraries are located under $TAPAS_HOME/lib/ .



Nevertheless, the classpath is also resolved in the manifest-file as follows:





 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andy Jung wrote:... isn't it already sufficient to invoke my jar (ts.jar) with -cp option where the classpath is specified?
All the libraries are located under $TAPAS_HOME/lib/ .



It is. But if you want the jar to be executable you would use the Class-Path entry (easier for the end user).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic