Replacing a class in the JAR package

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
YJ

Replacing a class in the JAR package

Post by YJ » Tue May 21, 2002 10:17 am

Hi all!

Need some pointers here...

I'm basically still very new in this Java programming thing and is a bit confused in the usage of packages and stuffs like that.

I've downloaded this JFreeChart thing but realised that I'll need to make small alterations to it to customise to what I want it to do...however, I'm now sure how to then put back the changed class into the JAR file package to replace the existing one.

Grateful for advices of any sort! Thanks in advance!

Best Regards,
YJ

Andrew Perepelytsya

Re: Replacing a class in the JAR package

Post by Andrew Perepelytsya » Wed May 22, 2002 3:19 pm

Generally you shouldn't. Just extend the class you need to modify and override the methods you need to alter.

But if u really need to put the class back to the jar file, then:

1. use the jar utility in your java/bin dir
2. Jar is simply a zip archive with a manifest file (it's simply a text file with some meta information). So, use your favourite zip archiver to repackage the dir. You can omit the manifest file, but generally that't not a good style

Cheers

Andrew Perepelytsya

Re: Replacing a class in the JAR package

Post by Andrew Perepelytsya » Wed May 22, 2002 3:21 pm

BTW, if smth in my previous post doesn't make sense to u, try java.sun.com/tutorial

YJ

Re: Replacing a class in the JAR package

Post by YJ » Thu May 23, 2002 7:45 am

Thanks for the info!

think you're pretty right about not changing the package...am now trying to work another way around it....

anyway, found another method to unpack and repack the Jar files if anyone's interested:

you can open the whole thing up as a directory tree by:
jar xf xxx.jar

and make whatever alteration you want..and then wrap it up again in a new jar by:
jar cf yyy.jar

Thanks again!

Locked