Results 1 to 8 of 8

Thread: Writing to jar

  1. #1
    jsobel is offline Member
    Join Date
    Apr 2012
    Posts
    68
    Rep Power
    0

    Default Writing to jar

    I need to write to a jar file so i can save data for my program is this possible plz help it is for storing scores in a game

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default Re: Writing to jar

    Are you trying to create a jar file or update an existing one? I'm not sure you can update an existing one, although the jar command can.
    That would be good to know if you can do it. Give it a try and let us know what happens.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jsobel is offline Member
    Join Date
    Apr 2012
    Posts
    68
    Rep Power
    0

    Default Re: Writing to jar

    I want to create and write to a text file in a allready created jar

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default Re: Writing to jar

    What have you tried? If you can not update an existing file, you could copy and update to a new file, delete the old file and rename the new file.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    jsobel is offline Member
    Join Date
    Apr 2012
    Posts
    68
    Rep Power
    0

    Default Re: Writing to jar

    OK. But i dont know how to create a file in a jar with a program i tried and it gave me a null pointer exception thanks anyway

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default Re: Writing to jar

    Quote Originally Posted by jsobel View Post
    OK. But i dont know how to create a file in a jar with a program i tried and it gave me a null pointer exception thanks anyway
    A jar file basically is a .zip file; this protocol is not meant to be updatable, i.e. if a .zip file (or .jar file) contains the entries A, B and C and you want to update entry B, you have to create a new .jar file, write entry A to it, the new entry B, and entry C. Next you throw away the old .jar file and rename the new .jar file.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    jsobel is offline Member
    Join Date
    Apr 2012
    Posts
    68
    Rep Power
    0

    Default Re: Writing to jar

    yes but i dont know how to do that with pure java

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default Re: Writing to jar

    Look at using the classes in the java.util.jar and java.util.zip packages.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Need Help W/ Writing to DB.
    By Sabinno in forum JDBC
    Replies: 2
    Last Post: 05-26-2011, 10:25 AM
  2. writing to ram
    By Timmins in forum New To Java
    Replies: 0
    Last Post: 04-03-2011, 09:52 AM
  3. Replies: 1
    Last Post: 02-27-2010, 02:29 AM
  4. Writing in XLS
    By selva.bics in forum Advanced Java
    Replies: 1
    Last Post: 11-09-2009, 10:09 AM
  5. writing to gui
    By rob in forum New To Java
    Replies: 2
    Last Post: 02-13-2009, 11:55 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
  •