This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class-Path variable in manifest file

 
Udayan Kumar
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to create a jar file which is custom utility. I need to package some extra 3rd party jars along with this jar & I am adding the same as part of manifest file when creating the custom jar file.

So here is the manifest file

---------------manifest.mf--------------------
Manifest-Version: 1.0
Created-By: Test User
Main-Class: au.com.test.integration.EventListener.class
Class-Path: activation-1.0.2.jar commons-codec-1.3.jar others.jar
-----------------------------------

Now when i run the jar utility something like this
_________________________________________

jar cfm testlistener.jar manifest.mf *.*
_________________________________________

So in the packaged testlistener.jar the manifest.mf under META-INF looks like this
---------------manifest.mf--------------------
Manifest-Version: 1.0
Created-By: Test User
Main-Class: au.com.test.integration.EventListener.class
-----------------------------------

It just skips the Class-Path attribute when creating the custom jar file.
Can anyone let me know if the above is the right way for doing the same.

Also i wanted to know if i create a separate folder called lib for all teh helper jars to my custom jar file then how do i put the same in my Class-Path attribute of Manifest.MF.
I tried to find the same but did not get much help on the same. How do i append the folder name in front of the jar file path.

Do let me know your comments on the same.

Regards,

Udayan
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just found this in the tutorial:

Warning : The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.

Does your manifest file end with a carriage return?
 
Udayan Kumar
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jesper,

Thanks for the reply. That worked.

But the only thing is now I see the jar utility adding the manifest file at 2 locations. One is from where I run the jar command so that gets added to the jar file & it also adds one manifest.mf under the META-INF folder. Ideally we need only one manifest.mf file as part of the package jar & i.e. the file under META-INF folder. How do i ignore the source manifest.mf being bundled as part of the jar & only keep the generated one - the one under META-INF.

Also I would like to know if we can add other external files say log4j.properties , xsl files, dtd files etc which is used by the main class as part of the jar & make our main class look for these files in the jar itself & do not need to actually put it on the classpath of the machine where we are supposed to execute the program unit.

Do post your response.


Regards,
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic