File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Ant version in runme.jar manifest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Ant version in runme.jar manifest" Watch "Ant version in runme.jar manifest" New topic
Author

Ant version in runme.jar manifest

Ronald Wouters
Ranch Hand

Joined: Apr 28, 2005
Posts: 190
Hi all,

I use Ant as a build tool and I just noticed the following in the manifest of my runme.jar file:



The line containing the Ant-version is automatically inserted by Ant itself when the build is done.
Will this be a problem ? Does this violate any musts ? Is it a possible cause for an automatic failure ?

Regards,
Ronald Wouters



Sun Certified Developer for the Java 2 Platform
Sun Certified Enterprise Architect for the Java Platform, Enterprise Edition 5
Jorj-Cezar Munteanu
Greenhorn

Joined: Feb 02, 2006
Posts: 7
Hi Roland,

It would help a lot if you included the relevant part from your build file; that is, the target that builds the jar. Until then, I suggest you to look to the jar task documentation, especially how to deal with external/internal manifest files.

Jorj
Ronald Wouters
Ranch Hand

Joined: Apr 28, 2005
Posts: 190
Hi Jorj,

here is the part of my buildfile that creates the runme.jar

and here is the full content of the runmeManifest.txt file


Regards,
Ronald.
Jorj-Cezar Munteanu
Greenhorn

Joined: Feb 02, 2006
Posts: 7
Hi Roland,

The line containing the Ant-version is automatically inserted by Ant itself when the build is done.


1. The "Ant-Version" line seems to be automatically inserted by ANT each time when using the jar task; unfortunately, I found no way to avoid it, though I have tested with both internal, external or merged manifests. Updating the jar will not work, too. A possible solution to this will be:
a. create the jar file.
b. unpack the MANIFEST.MF solely from the jar file
c. perform some modifications upon the manifest file, meaning that you remove that line
d. update the jar file with the new version but NOT WITH THE JAR TASK!

Well, this solution is not only tricky but it involves some several steps.
I found out another solution, better I think, for this. It is detailed in the 3rd item.

2.
The line containing the Ant-version is automatically inserted by Ant itself when the build is done.
Will this be a problem ? Does this violate any musts ? Is it a possible cause for an automatic failure ?


Well, I don't think that violates any must nor that it's subject of an automatic failure (God forbid). Not only because the same principle as using an IDE should apply here. But you never knows, so it's better to be safe than sorry. I am also using ANT but I didn't worried about this until now (thanks for raising this issue).

3. The solution which I recommend you is:



just make sure that your manifest file looks like:



and, of course, make sure that you modify this target to accordingly match your file names, structure and dependencies.

Hoping that helps you,
Ronald Wouters
Ranch Hand

Joined: Apr 28, 2005
Posts: 190
Hi Jorj,

thanks for your help.
I took a different approach of solving the problem on a "permanent" basis.
In the ant.jar of your ant distribution there is this:

[ronald@scrappy lib]$ jar -tf ant.jar | grep mf
org/apache/tools/ant/defaultManifest.mf

It is this defaultManifest.mf that contains the "Ant-Version" line.
I removed this line, re-jarred together my ant.jar, replaced the orignal ant.jar of the distribution with my "custom" version, executed my build file again and voila ... the line was "magically" gone, for ever...

Regards,
Ronald Wouters
[ February 07, 2006: Message edited by: Ronald Wouters ]
Jorj-Cezar Munteanu
Greenhorn

Joined: Feb 02, 2006
Posts: 7
Sorry, I made a typo mistake in my previous post. Please use <zip> instead of <jar>.
I forgot to change it back after I played a little with that target.
Jorj-Cezar Munteanu
Greenhorn

Joined: Feb 02, 2006
Posts: 7
Originally posted by Ronald Wouters:
Hi Jorj,

thanks for your help.
I took a different approach of solving the problem on a "permanent" basis.
In the ant.jar of your ant distribution there is this:

[ronald@scrappy lib]$ jar -tf ant.jar | grep mf
org/apache/tools/ant/defaultManifest.mf

It is this defaultManifest.mf that contains the "Ant-Version" line.
I removed this line, re-jarred together my ant.jar, replaced the orignal ant.jar of the distribution with my "custom" version, executed my build file again and voila ... the line was "magically" gone, for ever...

Regards,
Ronald Wouters

[ February 07, 2006: Message edited by: Ronald Wouters ]


Hi Roland,
Your solution is good, too. As we know, there is more than one good way to solve a issue. However, you must remember to do this with any ANT distribution which you'll use. If Eclipse is to be used, you must modify the corresponding plugin too.
Also, if the jar file is signed, you can go in trouble with this approach. But if it works, no problem
Bob Nedwor
hangman
Ranch Hand

Joined: Aug 17, 2005
Posts: 215

Please help ranchers, but I am curious as to why you would be using Ant if you want to pass the exam? Don't get me wrong. I use Ant and we all know it is one of the greatest tools ever invented. But if you read the bottom of http://www.sun.com/training/catalog/courses/CX-310-252A.xml which in part reads:
"The following APIs and facilities may not be used:...Third party software libraries or tools..."

Why would you ever consider using Ant if the rules say not to?? Or am I badly misinterpreting this???

Thanks for any attempts to clear this up.
[ February 14, 2006: Message edited by: Bob Nedwor ]

Bob N
SCJP - 1.4
SCJD - (B&S) Used 1.5 And It Runs On Solaris10
SCWCD - Thanks to HFSJ!!
Aruneesh Salhotra
Ranch Hand

Joined: May 12, 2004
Posts: 167
Bob,
Thats an interesting spin to the story.
At runtime, you are not using any third party libraries. I think thats exactly what Sun wants.

ANT is more of an IDE aid. But I am sure I wont submit my assignment created through ANT build file, until ofcourse someone convinces me do so now.
Bob Nedwor
hangman
Ranch Hand

Joined: Aug 17, 2005
Posts: 215

Thanks, Aruneesh. So you are basically saying it is ok to use Ant because it is not used when running the program? So a "SCDJ hopeful" could use Ant during the course of the project. But when it comes time to submit the final jar for upload, we should build/test/document everything manually and this would be perfectly acceptable? I am curious because I am going to sign up for the SCJD soon I don't want to throw away my $250.00.

Otherwise, it seems that there is some grey area here and that we should get a more definite response from someone like Bert Bates, right?

Thanks for any further info.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11525
    
100

Hi Bob,

When you sign up, you will get instructions from Sun on what is to be done, and what is allowable. These instructions take precedence over anything on the Sun site (especially on subjects like NIO).

All current versions of the assignments I have seen explicitly state that you are allowed to use IDEs, as long as there is no residual dependancy on them.

As such, you would be allowed to use Ant, so long as your project is capable of being built without it, and as long as you do not include any of the Ant libraries in your distribution.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11525
    
100

Oh, and for what it is worth, I submitted my assignment with the "Ant-Version" information still in the manifest - it certainly didn't hurt my score.

Regards, Andrew
Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
I submitted mine with Ant-Version: Apache Ant 1.6.2 in the manifest, and I don't think it affected my score.
Ronald Wouters
Ranch Hand

Joined: Apr 28, 2005
Posts: 190
Thanks all for your replies.
I guess I must have been a bit too paranoid about this "third party" stuff.

For what it's worth, the main reason for me to use ant is that it allows me to assemble my complete upload jar (including runme.jar, docs, choices.txt, etc...) from scratch in one go.
It compiles, runs rmic, javadoc, ... and finally jars it all together, in the correct/required layout, in my upload jar (scdja-spNNNNN.jar)
Having the capability to rebuild the whole thing as often as I want, allows me to test the jarred version (using runme.jar) often and early.
"Test often and early" ... sound familiar ?
And another thing, this is supposed to be a Java Developers exam. Is there one Java Developer amongst you who doesn't use Ant. If this exam is supposed to test our developers skills, then using Ant is certainly one of those skills. Just my five cents ...

Regards,
Ronald Wouters
Bob Nedwor
hangman
Ranch Hand

Joined: Aug 17, 2005
Posts: 215

Thanks so much to Andrew and everyone else. This makes sense. I feel much better! I am going to sign up for the SCJD today!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant version in runme.jar manifest