Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with packaging using ant

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I have the following structure:
Dir\src for source
Dir\build for class files
Dir\dist for storing the jar
Dir\images images used by the application
using ant, I want to create an executable jar file.
I wrote :

but the problem is, ant doesn't create images directory inside the Jar file, so the application will not working.
(when extracting the jar I found:
com/*.class
Meta-INF
image1.gif
image2.gif)
how to create the images directory inside the jar ??
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to include your "images" directory as part of the build. Right now you are just including all the files inside the "images" directory. Try something like this:

That should work for you if your "images" property is the value you want to show up in your JAR. If you need a different name, you'd have to do something like copy all your images to a temp directory whose name is the one you want, then do the same sort of thing.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please look at my build file:

now, the jar doesn't include the the images at all !!
how to create the images directory inside the jar ?
please help ....
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The nested include inside the fileset needs to be a relative URI. Since you have your "basedir" portion of your images attribute it messes everything up. Change to this:
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you alot.
but there is the last problem.
I have the class Manager under the package com, and as you see I have specified it within the manifest tag:
<attribute name="Main-Class" value="com.Manager"/>
but the jar file don't launch (it launch if I put my class without a package)....
so what is the problem ?
I appreciate your help...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic