Manifest file classpath

I have a jar file say a.jar.   In a.jar I have included b.jar , c.jar  and in the manifest file i have included like this

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: 1.6.0_27-b07 (Sun Microsystems Inc.)
Class-Path: c.jar b.jar

but my program does not find classes in b.jar. Though when I add b.jar explicitly to my classpath of my app it runs. Is Manifest file just informational or does it set any classpaths.


greenearthAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
>>but my program does not find classes in b.jar.

It won't. You can't nest jars without special measures such as

http://fjep.sourceforge.net/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
for_yanCommented:

if you need to put your a.jar and b.jar in classpath don't put them into enclosing .jar
if you want to make executable jar then it needs to have proper manifest.mf
0
greenearthAuthor Commented:
i received this jar from a third party and they have embedded the other jars in a jar along with other classes and added those jars in the manifest classpath
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

for_yanCommented:
That's strange - maybe they used it as just compressing method

If that would be executable - it should have pointer to the main class tl start the application

Try to extract them and put in classpath individually.
Do you know which is the main class to start application with java command ?
0
greenearthAuthor Commented:
in manifest file they have mentioned a main class ..but when I extract it that class is not present.

So with the previous example a.jar containing b.jar and c.jar ... after extracting a.jar , i have put the a.jar and b.jar it works but now it becomes a problem when i try to put this in the actual app. what happens there is app has another jar x.jar which has folder structure  abc.xyz
and b.jar also has the same structure abc.xyz. I guess these two conflict and at runtime I am not able to find the required classes. but the same thing works for standalone when i include a.jar,b.jar and x.jar
0
for_yanCommented:
>but the same thing works for standalone when i include a.jar,b.jar and x.jar

Sorry, didn't understand - so it works when you put them in the classpath ?
0
for_yanCommented:
If they have main class in manifest didn't you try to ruin it like that:

java -jar name_of_jar.jar MainClass  ..arguments...

0
for_yanCommented:
No I'm sorry you even odont need mainClass if this is executable jar


java -jar name_of_jar.jar   ..arguments...

0
greenearthAuthor Commented:
>but the same thing works for standalone when i include a.jar,b.jar and x.jar

>>Sorry, didn't understand - so it works when you put them in the classpath ?

yes it works for a standalone program in eclipse. But when I do the same as part of web application..its not able to find the classes in b.jar during runtime.
0
CEHJCommented:
>> But when I do the same as part of web application..its not able to find the classes in b.jar during runtime.

I'm not sure how you would or why you would run a java application 'as part of a  web application' but a web application looks for its jars in WEB-INF/lib
0
greenearthAuthor Commented:
it is the same code in standalone program and web app only diff is standalone has main class.  yes I have put the jars in WEB-INF/lib. but somehow I dont understand why it does not find the jars.
0
for_yanCommented:
>web app only diff is standalone has main class
this sounds a littel bit strange

So do you start irt as some servlet page?

Maybe you need to restart the server to recognize new jar files?
0
CEHJCommented:
Please post all error trace output, e.g. from the web app container's log
0
gordon_vt02Commented:
AFAIK no web container will look for nested JARs in an application's classpath.  They will only load classes and JARs found in WEB-INF/classes and WEB-INF/lib.  If you want to use that JAR in a web application, you'll have to extract b.jar and c.jar and include them in WEB-INF/lib as well as a.jar.
0
greenearthAuthor Commented:
the vendor fixed his code and gave the correct jar..
0
CEHJCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.