WebStart: How to read and write config data?

Discussion in 'Java' started by Andreas Schmidt, Dec 9, 2003.

  1. On Tue, 09 Dec 2003 17:37:55 -0500, Andreas Schmidt <>
    wrote:

    > I have a Web Start application. Now I want to add a login and user
    > preferences settings. Unfortunately, I don't know how to read and write
    > these data. What's the usual way to do it in this case? Open a socket
    > connection and read/write a file from the codebase URL? Is that allowed
    > to the Web Start application?


    I asked this question also in de.comp.lang.java, just in a thread that had
    a different original topic, so I decided to post it here. But I got the
    answer already there:

    Use muffins (analogous to cookies, just for WebStart applications)
    see PersistenceService on
    http://java.sun.com/products/javawebstart/docs/developersguide.html

    Or write a file into the user dir
    String configDir = System.getProperty("user.dir");

    Andi
     
    Andreas Schmidt, Dec 9, 2003
    #1
    1. Advertising

  2. I have a Web Start application. Now I want to add a login and user
    preferences settings. Unfortunately, I don't know how to read and write
    these data. What's the usual way to do it in this case? Open a socket
    connection and read/write a file from the codebase URL? Is that allowed to
    the Web Start application?

    Thanks!
    Andi
     
    Andreas Schmidt, Dec 9, 2003
    #2
    1. Advertising

  3. Andreas Schmidt

    Mike Guest

    Andreas Schmidt <> wrote in message news:<>...

    Like applets, you'd be in a sandbox, unless through signing and with
    the consent of the user you could write directly to disk.

    There is a Preferences class that I believe provides the ability to
    write some data while stilling remaining in a sandbox and not
    requiring a magic OK from the user (I'm assuming you want to avoid
    having to ask the user to allow your application full access to the
    system).

    As for the initial default data, you can only transport signed jar
    files, so no xml or txt files.
    What I do is I embed the data in a jar file, and use the class loader
    to read it:

    InputStream is = getClass().getClassLoader().getResourceAsStream("something.xml");

    The idea is that if the class itself was able to load from the jar
    file, you ought to be able to ask the class loader that loaded that
    class to load something else from that same jar file.

    You could save an altered version of the xml (or whatever) file to
    disk, say, to new File(System.getProperty("user.home"),
    "something.xml"); Next time you start you could do a file.isFile() to
    see if a version was previously written to disk, and if so, use it,
    and if not, use the default one from the jar file using the above
    code.



    > I have a Web Start application. Now I want to add a login and user
    > preferences settings. Unfortunately, I don't know how to read and write
    > these data. What's the usual way to do it in this case? Open a socket
    > connection and read/write a file from the codebase URL? Is that allowed to
    > the Web Start application?
    >
    > Thanks!
    > Andi
     
    Mike, Dec 10, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JL
    Replies:
    2
    Views:
    119
    Tim Chase
    Dec 14, 2013
  2. Cameron Simpson
    Replies:
    0
    Views:
    93
    Cameron Simpson
    Dec 15, 2013
  3. Chris Angelico
    Replies:
    0
    Views:
    100
    Chris Angelico
    Dec 15, 2013
  4. Tim Chase
    Replies:
    0
    Views:
    103
    Tim Chase
    Dec 16, 2013
  5. Cameron Simpson
    Replies:
    0
    Views:
    84
    Cameron Simpson
    Dec 18, 2013
Loading...

Share This Page