java.util.prefs

Discussion in 'Java' started by kimbuba, Jul 16, 2003.

  1. kimbuba

    kimbuba Guest

    Hello all.
    I'm playing with this new api.

    But i have some questions about it.

    I read that in windows preferences resides in:
    HKEY_CURRENT_USER\Software\JavaSoft\Prefs (for the user tree)
    On linux plat pref resides in: <user's home directory>/.java/.userPrefs

    The problem arises when i'm building a web application. If i write on the
    system tree i could read and write others preferences!

    My question is: is it possible to have a local pref tree? like a File? so
    that i can store that file locally on my hosting space?
    i'd like to be indipendent of my hosting provider, since i could have
    problems in writing on System tree or User tree (if they didn't configure
    well my account)

    Thanx all in advance.
     
    kimbuba, Jul 16, 2003
    #1
    1. Advertising

  2. kimbuba

    Mohun Biswas Guest

    Roedy Green wrote:
    >
    >>HKEY_CURRENT_USER\Software\JavaSoft\Prefs

    >
    >
    > Is HKEY_CURRENT_USER an alias for whomever is actually signed on right
    > now?


    Yes.

    It seems when you poke around in the registry there are large
    > parts duplicated.


    True.

    > I found Javasoft/prefs directories also in HKEY_LOCAL_MACHINE and
    > HKEY_USERS.
    >
    > Sun loves to play the shell game.


    That's as may be but what you describe is an artifact of the Windows
    registry. Many of the per-user settings are "backed" by per-machine
    settings in the HKEY_LOCAL_MACHINE tree. And in general, any search
    through the registry turns up huge duplicate trees, presumably as a
    result of some kind of aliasing/linking.

    MB
     
    Mohun Biswas, Jul 17, 2003
    #2
    1. Advertising

  3. kimbuba

    Mohun Biswas Guest

    Roedy Green wrote:
    >
    >>HKEY_CURRENT_USER\Software\JavaSoft\Prefs

    >
    >
    > Is HKEY_CURRENT_USER an alias for whomever is actually signed on right
    > now?


    Yes.

    It seems when you poke around in the registry there are large
    > parts duplicated.


    True.

    > I found Javasoft/prefs directories also in HKEY_LOCAL_MACHINE and
    > HKEY_USERS.
    >
    > Sun loves to play the shell game.


    That's as may be but what you describe is an artifact of the Windows
    registry. Many of the per-user settings are "backed" by per-machine
    settings in the HKEY_LOCAL_MACHINE tree. And in general, any search
    through the registry turns up huge duplicate trees, presumably as a
    result of some kind of aliasing/linking.

    MB
     
    Mohun Biswas, Jul 17, 2003
    #3
  4. On Wed, 16 Jul 2003 19:33:30 GMT, Roedy Green <> wrote:
    > On Wed, 16 Jul 2003 13:44:27 +0200, "kimbuba"
    > <> wrote or quoted :
    >
    > >HKEY_CURRENT_USER\Software\JavaSoft\Prefs

    >
    > Is HKEY_CURRENT_USER an alias for whomever is actually signed on right
    > now? It seems when you poke around in the registry there are large
    > parts duplicated.
    >
    > I found Javasoft/prefs directories also in HKEY_LOCAL_MACHINE and
    > HKEY_USERS.
    >
    > Sun loves to play the shell game.


    Sun's implementation of the Preferences on Windows
    goes something like this:

    User Root:
    HKEY_CURRENT_USER\Software\JavaSoft\Prefs

    System Root:
    HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs

    The effect is that is you want to share preferences across
    different users, put them in the System tree, not the User
    tree. The User tree will change based on the currently
    logged in user, so the preferences will necessarily be
    different. THe HKEY_CURRENT_USER hive is actually an
    alias for one of the hives in the HKEY_USERS hive, matching
    whoever the current user is.

    --Joe
     
    Joseph Millar, Jul 17, 2003
    #4
  5. kimbuba

    Andy Flowers Guest

    Try looking at the Preferences & PreferencesFactory classes for details of
    how you can provide your own preferences store.

    "kimbuba" <> wrote in message
    news:U0PRa.14337$...
    > is it possible to store the trees on a separate file?
    > If i put on the hosting's system tree, others people could read and modify
    > my preferences.
    >
    > Thnx.
    >
    >
    >
    >
    >
    > "Joseph Millar" <> ha scritto nel messaggio
    > news:...
    > > On Wed, 16 Jul 2003 19:33:30 GMT, Roedy Green <>

    wrote:
    > > > On Wed, 16 Jul 2003 13:44:27 +0200, "kimbuba"
    > > > <> wrote or quoted :
    > > >
    > > > >HKEY_CURRENT_USER\Software\JavaSoft\Prefs
    > > >
    > > > Is HKEY_CURRENT_USER an alias for whomever is actually signed on right
    > > > now? It seems when you poke around in the registry there are large
    > > > parts duplicated.
    > > >
    > > > I found Javasoft/prefs directories also in HKEY_LOCAL_MACHINE and
    > > > HKEY_USERS.
    > > >
    > > > Sun loves to play the shell game.

    > >
    > > Sun's implementation of the Preferences on Windows
    > > goes something like this:
    > >
    > > User Root:
    > > HKEY_CURRENT_USER\Software\JavaSoft\Prefs
    > >
    > > System Root:
    > > HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs
    > >
    > > The effect is that is you want to share preferences across
    > > different users, put them in the System tree, not the User
    > > tree. The User tree will change based on the currently
    > > logged in user, so the preferences will necessarily be
    > > different. THe HKEY_CURRENT_USER hive is actually an
    > > alias for one of the hives in the HKEY_USERS hive, matching
    > > whoever the current user is.
    > >
    > > --Joe

    >
    >
     
    Andy Flowers, Jul 18, 2003
    #5
  6. kimbuba

    kimbuba Guest


    >Try looking at the Preferences & PreferencesFactory classes for details of
    > how you can provide your own preferences store.
    >


    yes but in that way i'll break library standard.
    I think i'm going to go with the java.util.Properties
    I'll use preferences only for stand alone app.

    Thnx.
     
    kimbuba, Jul 18, 2003
    #6
  7. "kimbuba" <> wrote in message
    news:0BSRa.14774$...
    >
    > >Try looking at the Preferences & PreferencesFactory classes for details

    of
    > > how you can provide your own preferences store.
    > >

    >
    > yes but in that way i'll break library standard.
    > I think i'm going to go with the java.util.Properties
    > I'll use preferences only for stand alone app.


    You might also have a look at the following article.

    XML for Flexible Configuration
    Use XML as the basis for flexible configuration files by implementing the
    XMLConfig infrastructure
    by Claude Duguay
    http://www.fawcette.com/xmlmag/2001_12/magazine/columns/javabreak/default.asp
     
    Patrick Thrapp, Jul 18, 2003
    #7
  8. kimbuba

    Roedy Green Guest

    On Fri, 18 Jul 2003 15:27:23 +0200, "kimbuba"
    <> wrote or quoted :

    >
    > >Try looking at the Preferences & PreferencesFactory classes for details of
    >> how you can provide your own preferences store.


    If you don't need the nested structure, plain old Properties will do
    fine. They are effectively Hashtables with a simple key1=value text
    file external representation.

    see http://mindprod.com/jgloss/properties.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jul 18, 2003
    #8
  9. kimbuba

    kimbuba Guest

    i guess ur right.
    I will try to understand java's Preferences implementation.

    Thnx!


    "Andy Flowers" <> ha scritto nel messaggio
    news:R26Sa.760$...
    > Why would it break the standard library ?
    >
    > All you do is provide a PreferencesFactory which returns an instance of

    some
    > subclass of AbstractPreferences you create. You then provide the right
    > command line parameter to your application to specify which
    > PreferencesFactory to use and voila, preferences are stord where you want
    > them to be stored which may be a database or a centralised file system.
    >
    > To the application you write there will be no difference. It will still

    use
    > the Preferences API in all it's glory, all that will be different is that
    > operations will use you class.
    >
    > "kimbuba" <> wrote in message
    > news:0BSRa.14774$...
    > >
    > > >Try looking at the Preferences & PreferencesFactory classes for

    details
    > of
    > > > how you can provide your own preferences store.
    > > >

    > >
    > > yes but in that way i'll break library standard.
    > > I think i'm going to go with the java.util.Properties
    > > I'll use preferences only for stand alone app.
    > >
    > > Thnx.
    > >
    > >

    >
    >
     
    kimbuba, Jul 20, 2003
    #9
  10. kimbuba

    kimbuba Guest

    thnx 4 the mini tutorial!

    :)

    "Roedy Green" <> ha scritto nel messaggio
    news:...
    > On Fri, 18 Jul 2003 15:27:23 +0200, "kimbuba"
    > <> wrote or quoted :
    >
    > >
    > > >Try looking at the Preferences & PreferencesFactory classes for details

    of
    > >> how you can provide your own preferences store.

    >
    > If you don't need the nested structure, plain old Properties will do
    > fine. They are effectively Hashtables with a simple key1=value text
    > file external representation.
    >
    > see http://mindprod.com/jgloss/properties.html
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    kimbuba, Jul 20, 2003
    #10
  11. kimbuba

    kimbuba Guest

    i'll give a look.
    thnx!

    "Patrick Thrapp" <> ha scritto nel messaggio
    news:2_TRa.37787$...
    > "kimbuba" <> wrote in message
    > news:0BSRa.14774$...
    > >
    > > >Try looking at the Preferences & PreferencesFactory classes for

    details
    > of
    > > > how you can provide your own preferences store.
    > > >

    > >
    > > yes but in that way i'll break library standard.
    > > I think i'm going to go with the java.util.Properties
    > > I'll use preferences only for stand alone app.

    >
    > You might also have a look at the following article.
    >
    > XML for Flexible Configuration
    > Use XML as the basis for flexible configuration files by implementing the
    > XMLConfig infrastructure
    > by Claude Duguay
    >

    http://www.fawcette.com/xmlmag/2001_12/magazine/columns/javabreak/default.asp
    >
    >
    >
     
    kimbuba, Jul 20, 2003
    #11
    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. Oliver Hirschi

    java.util.prefs.Preferences

    Oliver Hirschi, Jul 16, 2003, in forum: Java
    Replies:
    8
    Views:
    8,774
    Chris Riesbeck
    Jul 16, 2003
  2. Veerle
    Replies:
    3
    Views:
    838
    Phil...
    Oct 24, 2003
  3. Me
    Replies:
    1
    Views:
    411
    Manish Pandit
    Sep 29, 2006
  4. Roedy Green
    Replies:
    10
    Views:
    2,060
    Mark Thornton
    Dec 30, 2007
  5. Mark Sizzler
    Replies:
    0
    Views:
    901
    Mark Sizzler
    Jun 1, 2009
Loading...

Share This Page