[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Manifest file classpath

Posted on 2011-10-11
16
Medium Priority
?
348 Views
Last Modified: 2012-05-12
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.


0
Comment
Question by:greenearth
  • 6
  • 5
  • 4
  • +1
16 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 600 total points
ID: 36951707
>>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
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 300 total points
ID: 36951730

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
 

Author Comment

by:greenearth
ID: 36951840
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Expert Comment

by:for_yan
ID: 36951870
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
 

Author Comment

by:greenearth
ID: 36951986
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
 
LVL 47

Expert Comment

by:for_yan
ID: 36952105
>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
 
LVL 47

Expert Comment

by:for_yan
ID: 36952112
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
 
LVL 47

Expert Comment

by:for_yan
ID: 36952123
No I'm sorry you even odont need mainClass if this is executable jar


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

0
 

Author Comment

by:greenearth
ID: 36952143
>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 36952236
>> 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
 

Author Comment

by:greenearth
ID: 36952287
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
 
LVL 47

Expert Comment

by:for_yan
ID: 36952330
>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 36952347
Please post all error trace output, e.g. from the web app container's log
0
 
LVL 10

Assisted Solution

by:gordon_vt02
gordon_vt02 earned 600 total points
ID: 36955887
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
 

Author Closing Comment

by:greenearth
ID: 37003356
the vendor fixed his code and gave the correct jar..
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 37003406
:)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month18 days, 21 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question