Results 1 to 9 of 9
  1. #1
    petec is offline Member
    Join Date
    Feb 2014
    Location
    Near Buffalo NY
    Posts
    33
    Rep Power
    0

    Default Combine Data WIth Program

    I have a program that has a fair amount of data and the user can add to or edit the data. I would like to somehow combine the data with the program so they are all just one file. Like everything is in xxx.jar. When the program ends the data should be appended or in some other way become part of the program.

    Then wherever xxx.jar goes, the latest version of the data goes with it.

    I am doing it with a separate data file now but it is a problem keeping the data file with the program file.

    Thanks,

    Pete

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

    Default Re: Combine Data WIth Program

    I don't know if you can update an existing jar file while the java program is using it as a source of class files.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,079
    Rep Power
    6

    Default Re: Combine Data WIth Program

    I think yes. The only thing you will not be able to do, on Windows at least, is to replace or remove the file itself. But its faster and more reliable to try it out than to ask about it.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    petec is offline Member
    Join Date
    Feb 2014
    Location
    Near Buffalo NY
    Posts
    33
    Rep Power
    0

    Default Re: Combine Data WIth Program

    But how can I replace or remove the file from the executing version of the program?

    Am I missing something? The closest I have come to doing this to save the data file in the folder where xxx.jar is. But I don't trust being able to "find" that folder on another computer.

    I'm using:

    Java Code:
    String workingdirectory=System.getProperty("user.dir");
    And it seems to get the right folder but who knows what will happen on another computer? And this will still require keeping xxx.jar and the data file together.

    I wish there was some way of creating a class or something that ended up being part of xxx.jar but could be changed during running.

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

    Default Re: Combine Data WIth Program

    part of xxx.jar but could be changed during running.
    As gimbal2 suggested: try it and see what happens.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,079
    Rep Power
    6

    Default Re: Combine Data WIth Program

    Let me sketch the situation you are trying to do here, to hopefully make you see that what you want to do is not really realistic.

    a) you work on a word document at work
    b) you want to be able to edit and read that word document at home too

    What you would do: take the word document home
    What you now want to do in your application: take the Word application home with the document packaged into the executable

    If the data is really tied to your application and you want access to it from different locations, a better solution is to put said data on a shared location which you can remotely access. Through an FTP server for example, or a database.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: Combine Data WIth Program

    If each user of the program is to have his own copy of the data, put the initial version in the jar file and then copy it to a persistent storage (like the registry on windows) for updating.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    petec is offline Member
    Join Date
    Feb 2014
    Location
    Near Buffalo NY
    Posts
    33
    Rep Power
    0

    Default Re: Combine Data WIth Program

    Thanks folks. I am looking into stashing it on my skydrive (now onedrive as of yesterday).

    I have to see if I can integrate the shared link to the file into my program.

    I may need some help there. If I do I'll start a new thread.

  9. #9
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,771
    Rep Power
    5

    Default Re: Combine Data WIth Program

    Unfortunately I can't find the post. But within the last year or so I believe Tolls had answered a similar question. I believe he said that an executable jar file may not modify itself. I may be misquoting him and I do not know if that applies here.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Combine Error
    By cloud in forum Eclipse
    Replies: 1
    Last Post: 12-07-2011, 09:26 AM
  2. Combine two S.O.P in one
    By javauserjava in forum New To Java
    Replies: 5
    Last Post: 04-05-2011, 06:27 AM
  3. can i combine this 2 code into one?
    By reeveliew in forum New To Java
    Replies: 3
    Last Post: 05-09-2010, 02:24 PM
  4. How can I do this? Combine variable.
    By PeterFeng in forum New To Java
    Replies: 5
    Last Post: 01-14-2009, 05:44 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
  •