Two Laptop Bag
The moose likes Ant, Maven and Other Build Tools and the fly likes How to include images directory in an executable jar? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "How to include images directory in an executable jar?" Watch "How to include images directory in an executable jar?" New topic
Author

How to include images directory in an executable jar?

Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
I created a deploy target in my Ant build script and wish to include my images directory into an executable jar...

This is the code to my deploy target:



If I created a property for my images directory, named ${images.dir}, how could I have it included inside this executable jar?

Many, many thanks!
[ February 28, 2006: Message edited by: Unnsse Khan ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26144
    
  66

Unnsse,
You can nest a <fileset> tag in the <jar> tag. The fileset represents a directory.


[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
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
Jeanne,

Thank you for your response!

I placed the following <fileset> tag in my deploy target as follows:


Typed "jar -tf Animation.jar" (from the command line) and received the following contents:



So, far so good... The images from my ${image.dir} were placed in the jar's root scope.

Now, when I tried to run this jar by issuing a "java -jar Animation.jar" (from the command line), the particular application launched but there were still no images present. Obviously, the images were not loaded...

Is it because the <fileset> places the images into the jar from ${images.dir}, instead of, copying the directory into the jar file?

Succinctly speaking, it seems that the <fileset> just copies the particular directory's contents (instead of the folder, along with its contents), inside the jar file.

When I looked up the <fileset> in the Ant manual, there was no sub tag (or nested tag, if you will ), such as a <mkdir>, allowable within <fileset> </fileset>.

Has anyone else come across the same problem?

How does one package the images directory, along with its contents, inside an executable jar file, using Ant?

With thanks,
[ March 01, 2006: Message edited by: Unnsse Khan ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to include images directory in an executable jar?
 
Similar Threads
Help with building executable jar with ant.
What does ${user.home} means ? Where is build .properties ?
How to automate deployment of war in Tomcat through Ant
Which IDE support JSP 2.0
package javax.ejb does not exist