Results 1 to 4 of 4
  1. #1
    Kyx
    Kyx is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default Updating a .jar File

    Ok, please bear with me, as it is kind of late and I might not be able to explain this as well as I could :rolleyes:

    Right, now I know basic Java (All self taught) Arrays, Variables, FileIO, little bit of Sockets, Swing, ect. But I am having trouble with something. Let's say I have two .jar files, one when run displays a Swing GUI with a TextBox, and Button, while the other contains a .txt file as a Resource (Is that the right word in Java? You know what I mean) And when run, displays a dialog box, which displays the content of the .txt file.

    Eg. The text file says "Cats", when run the program will say "Cats".

    So what I want to do, is have the first application, edit the .txt file inside the second. So If I put "Dogs" in the TextBox, and hit the button, it will change the .txt file of the Second .jar to "Dogs", and thus the second .jar will say "Dogs" when run. (Am I making any sense?)

    So I did some Googling, and it said about unpacking the .jar file, editing the .txt using normal FileIO, then repacking it. How would I got about going this?

  2. #2
    ArmenBaba is offline Member
    Join Date
    Aug 2010
    Posts
    9
    Rep Power
    0

    Default

    So these two .jar files are different programs that you run lets say by invoking them separately in the command line?
    If so this a an interprocess communication issue which I've never done it before but here is a link http://stackoverflow.com/questions/830641/is-it-possible-to-have-interprocess-communication-in-java.

    if not, its a concurrency issue read more here. Lesson: Concurrency (The Java™ Tutorials > Essential Classes)

    Hope this helps.
    I'm interested now in this matter, please write a tutorial if you figured this out and post the link here.

  3. #3
    Kyx
    Kyx is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default

    It looks like java.util.zip.ZipFile or java.util.jar.JarFile is what I need. Does anyone have any idea about this?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Use the JarFile class to get an InputStream to read a 'file' from a jar file.
    Also you can use the getResourceAsStream method to read a "file" from a jar file that is on the classpath.

    I'm not sure what your 2 jar files contain and how you are using them. You seem to be mixing the use of a jar file to hold class files with the execution of the class files contained in a jar.

    Googling, and it said about unpacking the .jar file, editing the .txt using normal FileIO, then repacking it.
    That would be how to "edit" a "file" contained in a jar file. The jar command would be used to rebuild the new jar file containing the edited file.

Similar Threads

  1. Updating JTabel
    By drwk in forum New To Java
    Replies: 2
    Last Post: 01-17-2010, 12:52 PM
  2. Updating my GUI
    By Catkill in forum AWT / Swing
    Replies: 6
    Last Post: 09-01-2009, 05:09 PM
  3. updating server side file using java bean
    By tskarthic in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-30-2009, 02:53 PM
  4. parsing and updating html file using JSP.
    By tskarthic in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-02-2009, 09:12 PM
  5. Saving and updating a single file
    By AkisV in forum Advanced Java
    Replies: 1
    Last Post: 09-27-2008, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •