Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to update a jar file for one source file change?

Reply
Thread Tools

How to update a jar file for one source file change?

 
 
NickName
Guest
Posts: n/a
 
      11-28-2006
Hi,

I'm new to java, so, I may get terminilogy wrong, bear with me. Here's
the problem. We use a set of tools to perform data extraction from a
repository into XML, then generate HTML for them. For this process,
we've got a BIG jar file that includes thousands of classes. Now,
recently a piece of data that includes section symbol, § was added to
the repository. The current extraction process does not include java
code for automatic translation into HTML encoded code, so, it stops the
HTML generation for this particular piece of data. Process-wise, it's
XML extraction from repository and then HTML (files) generation from
the XML files. As it stands, the second process of HTML generation for
this particular set of data failed.

Given the situation, we added the § to HTML encoded code to a piece of
java code that is being used during the data extraction and HTML
publishing process. However, when we ran a test, results indicate the
process has not translated the symbol, which also means that the
updated java source code was not being used. So, here are some
questions,
the BIG jar file uses some packages, one of which references this
particular java source code.
I've looked jar utility syntax, an inital thought was, to update this
jar file to recompile the updated java source code, however, however,
all the links/references on the web that I've looked at about jar
utility do not indicate how to update a jar file that includes an
updated java file.
Would using the u option alone update all? Then, it does not make
sense for the other thousands of files.

Secondly, how about re-package the package that reference this piece of
java code? Would the re-package recompiled all the referenced java
code/classes? Would I have to do something about the BIG jar file that
references this package or now it's been "updated"?

Many thanks.

 
Reply With Quote
 
 
 
 
Steve W. Jackson
Guest
Posts: n/a
 
      11-28-2006
In article < .com>,
"NickName" <> wrote:

> Hi,
>
> I'm new to java, so, I may get terminilogy wrong, bear with me. Here's
> the problem. We use a set of tools to perform data extraction from a
> repository into XML, then generate HTML for them. For this process,
> we've got a BIG jar file that includes thousands of classes. Now,
> recently a piece of data that includes section symbol, § was added to
> the repository. The current extraction process does not include java
> code for automatic translation into HTML encoded code, so, it stops the
> HTML generation for this particular piece of data. Process-wise, it's
> XML extraction from repository and then HTML (files) generation from
> the XML files. As it stands, the second process of HTML generation for
> this particular set of data failed.
>
> Given the situation, we added the § to HTML encoded code to a piece of
> java code that is being used during the data extraction and HTML
> publishing process. However, when we ran a test, results indicate the
> process has not translated the symbol, which also means that the
> updated java source code was not being used. So, here are some
> questions,
> the BIG jar file uses some packages, one of which references this
> particular java source code.
> I've looked jar utility syntax, an inital thought was, to update this
> jar file to recompile the updated java source code, however, however,
> all the links/references on the web that I've looked at about jar
> utility do not indicate how to update a jar file that includes an
> updated java file.
> Would using the u option alone update all? Then, it does not make
> sense for the other thousands of files.
>
> Secondly, how about re-package the package that reference this piece of
> java code? Would the re-package recompiled all the referenced java
> code/classes? Would I have to do something about the BIG jar file that
> references this package or now it's been "updated"?
>
> Many thanks.


I'm not sure if I correctly understand your question...but I *think*
you're asking how to update an existing jar file to replace some parts
and perhaps add new ones.

If so, then you can indeed use the -u flag to the jar command, and you
do not need to extract the jar's contents first or anything like that.
I've got an application with a jar where we did just that recently for
one user in need of a rapid bug fix.

To do so, I made the fix and locally compiled the corrected class. Then
I recreated only the portion of the package structure inside the jar
file that contained the modified class file(s). I was able to use a jar
command somewhat like this:

jar -uf myjarfile.jar com

Not all the sub-packages of com were present, as I said. I could well
have included sub-packages that weren't even in the jar before, like
com.newpkg, though it wasn't needed in my case. But the end result was
that the "com" package hierarchy inside my jar file remained intact
except that any class or other files inside my "com" directory ended up
replacing their old counterparts, or got added if they weren't there
before.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
 
Reply With Quote
 
 
 
 
NickName
Guest
Posts: n/a
 
      11-28-2006

Steve W. Jackson wrote:
> In article < .com>,
> "NickName" <> wrote:
>
>OP omitted.
>
> I'm not sure if I correctly understand your question...but I *think*
> you're asking how to update an existing jar file to replace some parts
> and perhaps add new ones.

Remove "and perhaps add new ones.", your understanding is perfect.

> If so, then you can indeed use the -u flag to the jar command, and you
> do not need to extract the jar's contents first or anything like that.
> I've got an application with a jar where we did just that recently for
> one user in need of a rapid bug fix.
>
> To do so, I made the fix and locally compiled the corrected class. Then
> I recreated only the portion of the package structure inside the jar
> file that contained the modified class file(s). I was able to use a jar
> command somewhat like this:
>
> jar -uf myjarfile.jar com


> Not all the sub-packages of com were present, as I said. I could well
> have included sub-packages that weren't even in the jar before, like
> com.newpkg, though it wasn't needed in my case. But the end result was
> that the "com" package hierarchy inside my jar file remained intact
> except that any class or other files inside my "com" directory ended up
> replacing their old counterparts, or got added if they weren't there
> before.


OK, got you. Great, thanks a bunch. As a side note, this knowledge is
so helpful that I think I'll move some of the backup files under the
same package hierarchy, good practice or real necessity? More likely
the late.

> = Steve =
> --
> Steve W. Jackson
> Montgomery, Alabama


 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      11-28-2006

NickName wrote:

> Secondly, how about re-package the package that reference this piece of
> java code?


Find yourself a build tool, like Ant, that can easily and automatically
re-build your JAR from scratch. Then do it. If you try to maintain a
product by modifying bits at a time, you'll go barking mad.

A damn good source control system will help too (Subversion is about
the best).

OTOH, JARs are just ZIP files with knobs on. There are any number of
tools, not all of them from the JDK, that can manipulate them for you.
It's not manipulating them that's hard, it's knowing what needs
manipulating.

 
Reply With Quote
 
NickName
Guest
Posts: n/a
 
      11-28-2006

NickName wrote:
> Steve W. Jackson wrote:
> > In article < .com>,
> > "NickName" <> wrote:
> >
> >OP omitted.
> >
> > I'm not sure if I correctly understand your question...but I *think*
> > you're asking how to update an existing jar file to replace some parts
> > and perhaps add new ones.

> Remove "and perhaps add new ones.", your understanding is perfect.
>
> > If so, then you can indeed use the -u flag to the jar command, and you
> > do not need to extract the jar's contents first or anything like that.
> > I've got an application with a jar where we did just that recently for
> > one user in need of a rapid bug fix.
> >
> > To do so, I made the fix and locally compiled the corrected class. Then
> > I recreated only the portion of the package structure inside the jar
> > file that contained the modified class file(s). I was able to use a jar
> > command somewhat like this:
> >
> > jar -uf myjarfile.jar com

>
> > Not all the sub-packages of com were present, as I said. I could well
> > have included sub-packages that weren't even in the jar before, like
> > com.newpkg, though it wasn't needed in my case. But the end result was
> > that the "com" package hierarchy inside my jar file remained intact
> > except that any class or other files inside my "com" directory ended up
> > replacing their old counterparts, or got added if they weren't there
> > before.

>
> OK, got you. Great, thanks a bunch. As a side note, this knowledge is
> so helpful that I think I'll move some of the backup files under the
> same package hierarchy, good practice or real necessity? More likely
> the late.
>


Additional notes:
Good news and bad news. The good news is, the jar update seems
successful, no error msg showing up after running the jar utility for
update per your instruction. The bad news is, the HTML generation for
that particular set of data still failed. And probably I know why, the
previous developer also uses JBuilder (from Borland probably) for this
process, and I noticed that for every java source code, there's an
equivalent of ?.jbx (JBuilder Executable?)

 
Reply With Quote
 
Wesley Hall
Guest
Posts: n/a
 
      11-28-2006
Andy Dingley wrote:
> NickName wrote:
>
>> Secondly, how about re-package the package that reference this piece of
>> java code?

>
> Find yourself a build tool, like Ant, that can easily and automatically
> re-build your JAR from scratch. Then do it. If you try to maintain a
> product by modifying bits at a time, you'll go barking mad.


+1

I could not agree with this more, trying to manually maintain archives
is a receipe of many wasted hours and IQ points. The fact that you have
mentioned (in a different reply) a problem related to someone else using
different tools in a different way is a big red light.

Check out ant. It looks big and scary when you first look but a few
examples (which are provided in the docs) will demonstrate how
straightforward it is. Then use this build script to build a fresh jar
file from your source files for each change. Once you have it working,
you will be able to build clean and consistent artifacts (in your case a
jar file) every time on every platform.


Once you have the build script working properly, everyone working on the
software should use that script to build the software and not their own
specific tools...
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      11-28-2006
NickName wrote:
....
> Good news and bad news. The good news is, the jar update seems
> successful, no error msg showing up after running the jar utility for
> update per your instruction. The bad news is, the HTML generation for
> that particular set of data still failed. And probably I know why, the
> previous developer also uses JBuilder (from Borland probably) for this
> process, and I noticed that for every java source code, there's an
> equivalent of ?.jbx (JBuilder Executable?)


2 points.
- A search on 'jbx file extension' should lead you
(fairly quickly) to a better definition within a couple
of clicks.
- I agree with Andy Dingley that an Ant build of the jar(s)
is the way to go, here. I have never found a use for jar
updating, but imagine there are any number of 'gotchas'
to consider. A fresh build of the Jar(s) should get around
(most of those) potential problems.

Andrew T.

 
Reply With Quote
 
NickName
Guest
Posts: n/a
 
      11-30-2006

Andrew Thompson wrote:
> NickName wrote:
> ...
>
> 2 points.
> - A search on 'jbx file extension' should lead you
> (fairly quickly) to a better definition within a couple
> of clicks.
> - I agree with Andy Dingley that an Ant build of the jar(s)
> is the way to go, here. I have never found a use for jar
> updating, but imagine there are any number of 'gotchas'
> to consider. A fresh build of the Jar(s) should get around
> (most of those) potential problems.
>
> Andrew T.


Thank you all. Will try to find time to look into ant etc.
recommendation.

 
Reply With Quote
 
NickName
Guest
Posts: n/a
 
      12-01-2006

NickName wrote:
> Andrew Thompson wrote:
> > NickName wrote:
> > ...
> >
> > 2 points.
> > - A search on 'jbx file extension' should lead you
> > (fairly quickly) to a better definition within a couple
> > of clicks.
> > - I agree with Andy Dingley that an Ant build of the jar(s)
> > is the way to go, here. I have never found a use for jar
> > updating, but imagine there are any number of 'gotchas'
> > to consider. A fresh build of the Jar(s) should get around
> > (most of those) potential problems.
> >
> > Andrew T.

>
> Thank you all. Will try to find time to look into ant etc.
> recommendation.


Hi all,

Let me re-phrase or expand the question a bit. First of all, imho, the
process fails this little symbol is no big deal at all, it's not a show
stopper, not critical at all (Initially I just got rid of this symbol
and let 99.9999999999% of data going through, what is MOST IMPORTANT
would be to use these data, get some value out of it). So, taking the
time and effort to fix it, for one thing, is to accomodate some old
cranky but seemingly more senior guy in the current environment, and
secondly, an opportunity for myself to get into java programming area,
which would be a (skill) addition to my current environment and
possibly future as well;
and thirdly, in case, some more serious problem pops down the road if
we have to keep on using the current process, which is very convoluted
btw.
Hence, the motivation to go a step further. Having said that, noce
againI truly appreciate everyone's ideas/thoughts/advices and thanks
for putting up with my whining.

OK. Good to know that an "update" (even without recompilation error)
may not work.
For fresh build, guess one would use build tool to do it. So, along
this line of thinking, ant is recommended. Any more thoughts as to why
it is better or a beginner like me should use it instead of JBuilder,
which I happen to have a copy?

Many thanks.

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      12-01-2006
NickName wrote:
....
> For fresh build, guess one would use build tool to do it. So, along
> this line of thinking, ant is recommended. Any more thoughts as to why
> it is better or a beginner like me should use it instead of JBuilder,
> which I happen to have a copy?


Doesn't JBuilder run Ant scripts? In any case, I imagine
it should have a button or menu item to creat a Jar.
(The reason people specifically think 'Ant' is because
it is portable between other tools).

Andrew T.

 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 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