?
Solved

Updating a Jar File

Posted on 2005-03-09
14
Medium Priority
?
1,141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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!

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

762 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