Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > replace files in a jar...

Reply
Thread Tools

replace files in a jar...

 
 
David N. Welton
Guest
Posts: n/a
 
      11-05-2005
I can't seem to find a way to force this:

[jar] org/hecl/BasicMathCmd.class omitted as
org/hecl/BasicMathCmd.class is up to date.

[jar] org/hecl/EqualsCmd.class omitted as org/hecl/EqualsCmd.class
is up to date.

[jar] org/hecl/IntThing.class omitted as org/hecl/IntThing.class
is up to date.

I want these to always be replaced. Is there a way to get ant to do
this? So far I have:

<jar destfile="Hecl.jar" basedir="build/float" update="true"/>

I don't see any options in the documentation that seem like they'll do
what I want... any ideas on how to get around this problem?

Thanks!
--
David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/
 
Reply With Quote
 
 
 
 
zero
Guest
Posts: n/a
 
      11-05-2005
"David N. Welton" <> wrote in news:436d00dd$0$6007
$:

> I can't seem to find a way to force this:
>
> [jar] org/hecl/BasicMathCmd.class omitted as
> org/hecl/BasicMathCmd.class is up to date.
>
> [jar] org/hecl/EqualsCmd.class omitted as org/hecl/EqualsCmd.class
> is up to date.
>
> [jar] org/hecl/IntThing.class omitted as org/hecl/IntThing.class
> is up to date.
>
> I want these to always be replaced. Is there a way to get ant to do
> this? So far I have:
>
> <jar destfile="Hecl.jar" basedir="build/float" update="true"/>
>
> I don't see any options in the documentation that seem like they'll do
> what I want... any ideas on how to get around this problem?
>
> Thanks!


I don't know about ant, but if I remember correctly you can't replace files
inside a jar without recreating the complete jar. This is because of the
format of jars.
 
Reply With Quote
 
 
 
 
Rhino
Guest
Posts: n/a
 
      11-06-2005

"zero" <> wrote in message
news:Xns9705D2D51885Fzerothishi@195.130.132.70...
> "David N. Welton" <> wrote in news:436d00dd$0$6007
> $:
>
> > I can't seem to find a way to force this:
> >
> > [jar] org/hecl/BasicMathCmd.class omitted as
> > org/hecl/BasicMathCmd.class is up to date.
> >
> > [jar] org/hecl/EqualsCmd.class omitted as org/hecl/EqualsCmd.class
> > is up to date.
> >
> > [jar] org/hecl/IntThing.class omitted as org/hecl/IntThing.class
> > is up to date.
> >
> > I want these to always be replaced. Is there a way to get ant to do
> > this? So far I have:
> >
> > <jar destfile="Hecl.jar" basedir="build/float" update="true"/>
> >
> > I don't see any options in the documentation that seem like they'll do
> > what I want... any ideas on how to get around this problem?
> >
> > Thanks!

>
> I don't know about ant, but if I remember correctly you can't replace

files
> inside a jar without recreating the complete jar. This is because of the
> format of jars.


I've always believed that there is no way to delete or replace an entry from
a zip or a jar. As far as I knew, you have to create a new jar that has the
desired files in it.

However, according to the Ant user manual,
http://ant.apache.org/manual/index.html, the Jar and Zip tasks have an
'update' flag. Apparently:

---
The update parameter controls what happens if the ZIP file already exists.
When set to yes, the ZIP file is updated with the files specified. (New
files are added; old files are replaced with the new versions.) When set to
no (the default) the ZIP file is overwritten if any of the files that would
be added to the archive are newer than the entries inside the archive.

[The update parameter is supposed to behave the same for the Jar task as for
the Zip task.]
---

Unfortunately, the examples in the articles for the Zip and Jar tasks are
not very helpful. Perhaps the original poster should ask on the ant user
mailing list? That is a fairly active list and some very experienced Ant
users hang out there to help. This page - http://ant.apache.org/mail.html -
gives instructions on joining the mailing list. A search of the Ant archives
for the 'user' list might also turn up useful information. You can access
that archive at the same page and search the archive for keywords.

Or maybe someone will come along who has used the update flag in a Jar task
who can explain what the original poster is doing wrong.

The only possibility that occurs to me is based on this sentence from both
the Jar and Zip tasks:

---
Please note that ZIP files store file modification times with a granularity
of two seconds. If a file is less than two seconds newer than the entry in
the archive, Ant will not consider it newer.
---

Is it possible that the new versions of the files that are to be replaced in
the jar have two seconds or less difference in their timestamps?

Rhino




 
Reply With Quote
 
eai-notes eai-notes is offline
Junior Member
Join Date: Feb 2010
Location: San Francisco Bay Area
Posts: 1
 
      02-28-2010
One has to use the JAR utility that comes bundled with JDK to modify JARS ..for example, to change a class file. You cannot use programs like WinZIP/WinRAR.

This post has more details:
eai-notes.blogspot.com/2010/02/modifying-jar-files.html

thanks,
Aj
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace /n with a XHTML <br /> using string.replace Alun ASP .Net 3 02-18-2008 05:52 AM
Re: [Pyrex] pyrex functions to replace a method (Re: replace a method Greg Ewing Python 2 06-29-2006 05:25 PM
pyrex functions to replace a method (Re: replace a method in class:how?) Brian Blais Python 1 06-27-2006 12:13 PM
s/$match/$replace/ fails when $replace has backreferences anonyusenet@yahoo.com Perl Misc 3 09-12-2005 11:03 AM
help with string replace - for doing selective replace Prasad S Javascript 2 08-27-2004 03:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57