Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Creating a Jar (NON executable) with all the dependencies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Creating a Jar (NON executable) with all the dependencies" Watch "Creating a Jar (NON executable) with all the dependencies" New topic

Creating a Jar (NON executable) with all the dependencies

Jayanath Amaranayake

Joined: Dec 06, 2009
Posts: 7
I have some set of utility java classes. They use commons bean utils and some other third party jar files. I created a jar of my utility classes (This jar is NOT executable as it contains only some utility classes that can be used by others) and added the Class-Path attribute to the manifest file at the time of the Jar file creation. However when another application is trying to use my utility classes jar, it fails with a ClassNotFound as my utility classes failed to find its dependencies.
May be I have missed something here. But below is a generic example of my scenario.

Utility.jar - has some utility classes and has no entry point with a main method
Dependancy1.jar - used in Utility.jar
Dependancy2.jar - used in Dependancy1.jar

Now, how should I create the Utility.jar properly, with all the dependencies.

Appreciate your help and many thanks for your time.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

Check out the Class-Path manifest property. It should be a location relative to the JAR file itself.

How To Ask Questions How To Answer Questions
jQuery in Action, 2nd edition
subject: Creating a Jar (NON executable) with all the dependencies
Similar Threads
jboss-ide ClassNotFoundException
Trouble accessing a servlet in a jar file
log4j setting in enterprise project structure
Classpath problems
Instantiating classes in jar file used by Web project