where to have same user.home path or share same properties

Discussion in 'Java' started by John_Woo, Jul 21, 2006.

  1. John_Woo

    John_Woo Guest

    Hi,

    if an app writes to a file, the location may be user.home, in Windowns
    it is okay, but in unix, different user have different full-path.

    I'm wondering, what's the idea to have unique full-path, which is
    cross-platform? That way same app, event executed twice/more at the
    same time in same machine, can share same file.

    or, better idea to have same app run in different JVM <same machine>
    share a properties, like System.getProperties("my app") always return
    same value? -- it may be done by socket, rmi,..but it doesn't sound
    good.

    --
    Thanks
    John
    Toronto
     
    John_Woo, Jul 21, 2006
    #1
    1. Advertising

  2. In article <>,
    "John_Woo" <> wrote:

    > Hi,
    >
    > if an app writes to a file, the location may be user.home, in Windowns
    > it is okay, but in unix, different user have different full-path.


    In Windows 98, every user's home directory is in the same location. In
    newer versions, each user account has a home directory of its own just
    as in Unix (and they could be shared among users, as they also could in
    Unix).

    > I'm wondering, what's the idea to have unique full-path, which is
    > cross-platform? That way same app, event executed twice/more at the
    > same time in same machine, can share same file.


    I suggest you check out the Java Preferences API as one possible
    solution. It allows user-level preferences or system-level preferences
    to be created and maintained. Where the information is stored for these
    is system-dependent and transparent to your application. In Windows,
    it's typically in the Registry. In the Linux system I've used, it's in
    a user's .java/.userPrefs directory structure. On Mac OS X, it's in a
    PList file in the user's own ~/Library/Preferences directory.

    > or, better idea to have same app run in different JVM <same machine>
    > share a properties, like System.getProperties("my app") always return
    > same value? -- it may be done by socket, rmi,..but it doesn't sound
    > good.
    >
    > --
    > Thanks
    > John
    > Toronto


    From the last part, I'm not quite clear on what it is you really want to
    accomplish, so I can't offer much more than I have above.

    = Steve =
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Jul 21, 2006
    #2
    1. Advertising

  3. John_Woo

    John_Woo Guest

    Steve W. Jackson wrote:
    > In article <>,
    > "John_Woo" <> wrote:
    >
    > > Hi,
    > >
    > > if an app writes to a file, the location may be user.home, in Windowns
    > > it is okay, but in unix, different user have different full-path.

    >
    > In Windows 98, every user's home directory is in the same location. In
    > newer versions, each user account has a home directory of its own just
    > as in Unix (and they could be shared among users, as they also could in
    > Unix).
    >
    > > I'm wondering, what's the idea to have unique full-path, which is
    > > cross-platform? That way same app, event executed twice/more at the
    > > same time in same machine, can share same file.

    >
    > I suggest you check out the Java Preferences API as one possible
    > solution. It allows user-level preferences or system-level preferences
    > to be created and maintained. Where the information is stored for these
    > is system-dependent and transparent to your application. In Windows,
    > it's typically in the Registry. In the Linux system I've used, it's in
    > a user's .java/.userPrefs directory structure. On Mac OS X, it's in a
    > PList file in the user's own ~/Library/Preferences directory.
    >
    > > or, better idea to have same app run in different JVM <same machine>
    > > share a properties, like System.getProperties("my app") always return
    > > same value? -- it may be done by socket, rmi,..but it doesn't sound
    > > good.
    > >
    > > --
    > > Thanks
    > > John
    > > Toronto

    >
    > From the last part, I'm not quite clear on what it is you really want to
    > accomplish, so I can't offer much more than I have above.
    >
    > = Steve =
    > --
    > Steve W. Jackson
    > Montgomery, Alabama


    Thanks Steve.

    Can you tell how to make java app write an entry to Registry <for
    windows os>?

    the last question was: any simple way for an app to set system
    properties, and other app <event though same app, but running in other
    folder> can get this properties?

    --
    John
     
    John_Woo, Jul 21, 2006
    #3
  4. In article <>,
    "John_Woo" <> wrote:

    [ snip ]

    > Thanks Steve.
    >
    > Can you tell how to make java app write an entry to Registry <for
    > windows os>?
    >
    > the last question was: any simple way for an app to set system
    > properties, and other app <event though same app, but running in other
    > folder> can get this properties?
    >
    > --
    > John


    I gave you the clue to what I was suggesting in the earlier post, which
    is the use of Preferences in Java (introduced in 1.4).

    <http://java.sun.com/j2se/1.4.2/docs/api/java/util/prefs/Preferences.html
    >


    <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html
    >


    You might use the static systemNodeForPackage method there, for example.
    If you have a class at com.acme.myclass, the system-level preference
    node would be created for "com.acme". On Windows, it happens that the
    stored preference data would be in the Registry. But that's not really
    important. What is important is that information can be placed there
    once and then is accessible to other users in the same way to read it.

    A warning is in order, though, if you want to use this for communication
    between running applications. It's not a good idea and may not work
    reliably.

    And Preferences may still not be the best solution for whatever problem
    you're actually trying to solve, which you haven't actually said clearly
    so far.
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Jul 21, 2006
    #4
    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. Max2006
    Replies:
    2
    Views:
    537
    Max2006
    Jul 13, 2007
  2. nancyflorida
    Replies:
    0
    Views:
    371
    nancyflorida
    Nov 12, 2007
  3. nancyflorida
    Replies:
    0
    Views:
    358
    nancyflorida
    Nov 12, 2007
  4. * Its my Pleasure *
    Replies:
    0
    Views:
    402
    * Its my Pleasure *
    Feb 20, 2008
  5. Saraswati lakki
    Replies:
    0
    Views:
    1,417
    Saraswati lakki
    Jan 6, 2012
Loading...

Share This Page