Link to home
Create AccountLog in
Avatar of oliverUK
oliverUK

asked on

Updating a Jar File

I am having a problem creating a jar file

1)I successfully archived my classes in by :-
    jar uf myFile.jar *.class

2)I successfully updated my manifest to specify entry point by:-
   jar cmf myManifestFile myFile.jar *.class

3) I want to archive an images directory into the jar that my application uses- here is my problem!
         I try "jar uf myfile.jar images"
 but I keep getting back
         java.io.IOException: Error in writing existing jar file
        at sun.tools.jar.Main.run(Main.java:177)
        at sun.tools.jar.Main.main(Main.java:903)

What am I doing wrong?

Thanks

Avatar of zzynx
zzynx
Flag of Belgium image

See http://java.sun.com/docs/books/tutorial/jar/basics/update.html

I think you can't pass a directory.

does
  jar uf myfile.jar images/MyImage.gif
work?


replace "MyImage.gif" by one of yours of course
Avatar of oliverUK
oliverUK

ASKER

I have already tried that, I get the same error.

Also you can archive directories :-

http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/jar.html

Then it seems as your original jar file can't be found or overwritten
Just add only the folder and see that all the images inside the folder are added.
jar cv0f Images.jar Images ------> 0f means no compression for the Images
jar uvf classes.jar  *.class -C mydir/mysubdir/yimages
After Adding your Images to your Jar file then in your Java program you must use

ImageIcon img = new ImageIcon(this.getClass().getResource("Images\YourImage.gif");

to see the Icon.
ASKER CERTIFIED SOLUTION
Avatar of ashok3sep
ashok3sep

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
oliverUK,
The link I gave in my first comment was a specific link of a whole Lesson: "Using JAR Files: The Basics."
ashok's comment is just a copy/paste out of another part of that lesson.
I would have expected a split.
Thanks for accpeting

:-)

zzynx is right
Thanks ashok.


If you want this question to be reopened, post a zero-point question in https://www.experts-exchange.com/Community_Support/

Subject: Moderator Please Reopen
Body: Please reopen this question:
https://www.experts-exchange.com/questions/21343414/Updating-a-Jar-File.html

Once reopened, you can perform a split.
Yes splitting points is fair, apologies zzynx and thank you both for your input.

Regards

OliverUK
>> Yes splitting points is fair
Thanks