Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Updating a Jar File

Posted on 2005-03-09
14
Medium Priority
?
1,212 Views
Last Modified: 2008-02-01
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

0
Comment
Question by:oliverUK
  • 6
  • 6
  • 2
14 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 13494545
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?


0
 
LVL 37

Expert Comment

by:zzynx
ID: 13494548
replace "MyImage.gif" by one of yours of course
0
 

Author Comment

by:oliverUK
ID: 13494599
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

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 37

Expert Comment

by:zzynx
ID: 13494636
Then it seems as your original jar file can't be found or overwritten
0
 
LVL 5

Expert Comment

by:ashok3sep
ID: 13495078
Just add only the folder and see that all the images inside the folder are added.
0
 
LVL 5

Expert Comment

by:ashok3sep
ID: 13495092
jar cv0f Images.jar Images ------> 0f means no compression for the Images
0
 
LVL 5

Expert Comment

by:ashok3sep
ID: 13495108
jar uvf classes.jar  *.class -C mydir/mysubdir/yimages
0
 
LVL 5

Expert Comment

by:ashok3sep
ID: 13495132
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.
0
 
LVL 5

Accepted Solution

by:
ashok3sep earned 225 total points
ID: 13495196
This is an example from Java Sun website.........

C:\Java> jar cvf bundle.jar audio classes images
adding: audio/1.au
adding: audio/2.au
adding: audio/3.au
adding: audio/spacemusic.au
adding: classes/Animator.class
adding: classes/Wave.class
adding: images/monkey.jpg
adding: images/at_work.gif

Regards,

Freedom
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13496218
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.
0
 
LVL 5

Expert Comment

by:ashok3sep
ID: 13496282
Thanks for accpeting

:-)

zzynx is right
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13496420
Thanks ashok.


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

Subject: Moderator Please Reopen
Body: Please reopen this question:
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21343414.html

Once reopened, you can perform a split.
0
 

Author Comment

by:oliverUK
ID: 13496475
Yes splitting points is fair, apologies zzynx and thank you both for your input.

Regards

OliverUK
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13496680
>> Yes splitting points is fair
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question