wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Manifest Classpath problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Manifest Classpath problem" Watch "Manifest Classpath problem" New topic
Author

Manifest Classpath problem

pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Hi,
I have a ant script that creates a jar with the following dir structure

MyProject.jar
-lib (contains asm-all-2.1.jar)
-myPackageDir

How can i set the class-path to the asm-all-2.1.jar in the lib Directory?



[<a href="http://cyvis.sourceforge.net" target="_blank" rel="nofollow">CyVis - Software Complexity Visualiser</a>] [<a href="http://pradeepselvaraj.blogspot.com" target="_blank" rel="nofollow">Pradeep's Blog</a>]
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Can you set this up without using ant?

If you can, then tell me how? If you cannot, then ant cannot do it.

As far as I know, you cannot set classpath to point to a nested jar inside another jar. I could be wrong on this, let me know...

I think I have a simple solution for you. When you jar the outer jar, you can put all the inner jar contents inside the outer jar. Then your problem is solved.

Thanks!
pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Do you mean domething like this?

=============
myapp.jar
-dependent.jar
-mypackageDir
===============

====OR========
HomeDIR
-dependent.jar
-myapp.jar
--mypackageDIR
==============

Since i am writing an AntTask, I prefer the first method. If i use the second mthod (which is working) then the jar should always dependent on external things. Can someone let me know how to set the classpath if using the first method?

Thank You
[ June 15, 2006: Message edited by: pradeep selvaraj ]
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
I think I misunderstood your question, ignore my previous answer. I thought you wanted to include another jar inside the jar. Sorry!

Now, I am not sure what you really want. However, my suggestion is writing a batch or shell script to do what you want, then you will know how to it with ant.

GOOD LUCK!
Nikhil Goel
Ranch Hand

Joined: Jul 11, 2003
Posts: 32
Zhang you are right . As according to jar specs from SUN at http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#JAR%20Manifest you can't have classpath as an attribute in a jar manifest.
Summary is ant will also not allow you to do this .

What you can do is include smaller jars in the bigger jar and then put bigger jar in the classpath .
pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Hi Zhang,
You got it right in the first reply, but i did not understnad what you ment by this

Originally posted by Roseanne Zhang:


I think I have a simple solution for you. When you jar the outer jar, you can put all the inner jar contents inside the outer jar. Then your problem is solved.



Could you please explain.

Thanks
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
If that is the case, you can use ant <unjar> task to unjar the inner jar into a temp directory, then <jar> everything together. Set your Class-Path and Main-Class to the proper ones.

Good luck!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Manifest Classpath problem