This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes How do I set the classpath to access JARS contained within a Jar File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do I set the classpath to access JARS contained within a Jar File" Watch "How do I set the classpath to access JARS contained within a Jar File" New topic
Author

How do I set the classpath to access JARS contained within a Jar File

Rob Tanner
Greenhorn

Joined: Apr 10, 2009
Posts: 18
Hi,

I am trying to build a single jar file containing two executables and the jar files they need to function (i.e., for MySQL access, to mail results, XML processing, log4j, etc). There is no default class and therefore each of the two executables are accessed by it's full package name with the CLASSPATH environment variable set to the name of the containing jar file, e.g.:



Inside the manifest, I am setting the Class-Path attribute to "lib/mail.jar lib/log4j-1.2.15.jar lib/xmlrpc-2.0.1.jar lib/xerces.jar lib/pcng-server-11.6.jar lib/commons-codec-1.3.jar lib/linfield.jar" which is their path within the jar file. The problem is that java isn't finding them. Am I doing something wrong or trying to do something that isn't supported in Java 6?

Thanks,
Rob Tanner
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Rob,
Java isn't designed to read nested jars. Any reason you can't unjar it and have the jars "loose"?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: How do I set the classpath to access JARS contained within a Jar File
 
Similar Threads
Defining Ant build.xml java properties files for a run targer
Can't read property file in log4j
PATH Vs. CLASSPATH settings
RunJavaApplication As Executable Jar
Problem in setting up Classpath variable in Win ME