Preferences API on windows

Does anyone know where it puts these key/value pairs?

Annoyingly: the registry (that flaky binary black boxish monstrosity Microsoft is keeping around for Windows Vista).
Unix JVMs come with a Preferences implementation that uses files in the user's home directory--I'd like to see it brought over to Windows; I like the simplicity of the API but hate the registry lock in.

Similar Messages

  • Preference API in windows when registry is blocked

    Hi All,
    I have a requirement to save the user preferences of a swing based medical application at the user end and the Preferences API seemed clean to fit the bill.
    However after going live, we found that some workstations have been denied user access to the registry. In such cases the entire application seems to fail. Please suggest some way out. It is exteremely important as we have already gone live with the software in place and some doctors may not be able to use the system. For the time being I could start using a properties file as a back up and storing using the random-access file api. Please help......
    Thanks in advance,
    Zeus

    A cursory look at the Preferences.java source leads me to believe that it should be possible to change where the values are stored. This code interrogates the os.name and chooses either the Windows Registry or something else (I assume a file it creates.)
    // 3. Use platform-specific system-wide default
    String platformFactory =
        System.getProperty("os.name").startsWith("Windows")
        ? "java.util.prefs.WindowsPreferencesFactory"
        : "java.util.prefs.FileSystemPreferencesFactory";
    try {
        return (PreferencesFactory)
         Class.forName(platformFactory, false, null).newInstance();
    } catch (Exception e) {
        InternalError error = new InternalError(
         "Can't instantiate platform default Preferences factory "
         + platformFactory);
        error.initCause(e);
        throw error;
    }You should be able to subclass this class and change so that the Registry isn't used.

  • Java.utils.prefs.Preferences API throws exception on Mac, not Windows

    This is a Mac-specific problem. Is it a bug, or am I misusing the java.utils.prefs.Preferences API?
    The Preferences flush() API call always throws a BackingStoreException if a system tree preferences root has been read. The system tree has not been modified or written to, but the flush() call is nevertheless throwing an exception. This occurs when running as a normal user without the ability to write to /Library/Preferences.
    See sample code below. Note that I only want to read the system prefs tree. The user tree write flush fails. If the system tree node is not created, the user flush() succeeds.
    Steps to Reproduce
    Delete any existing Java prefs files:
    ~/Library/Preferences/com.apple.java.util.prefs.plist
    ~/Library/Preferences/com.mycompany.prefstest
    /Library/Preferences/com.apple.java.util.prefs.plist
    /Library/Preferences/com.mycompany.prefstest
    Run the following Java code:
    package com.mycompany.prefstest;
    import java.util.prefs.BackingStoreException;
    import java.util.prefs.Preferences;
    public class PrefsTest {
          * @param args
         public static void main(String[] args) {
              String strKey1 = "com/mycompany/prefstest/one/two/three/four/key1";
              Preferences systemRoot = Preferences.systemRoot();
              Preferences userRoot = Preferences.userRoot();
              // Get a value for user prefs.
              String value1 = userRoot.get(strKey1, "missing");
              // Fall back to system prefs if it is not defined.
              if (value1.equals("missing"))
                   value1 = systemRoot.get(strKey1, "missing");
              System.out.println("key1 --> " + value1);
              // If still not defined, set a user-specific value
              if (value1.equals("missing"))
                   userRoot.put(strKey1, "value1");
                   try {
                        userRoot.flush();
                        System.out.println("flushed prefs successfully");
                   catch (BackingStoreException e)
                        System.out.println("Exception: " + e.toString());
    Expected Results
    Should produce the output:
    key --> missing
    flushed prefs successfully
    Actual Results
    Console output is
    key --> missing
    Exception: java.util.prefs.BackingStoreException: Synchronization failed for node '/'
    Notes
    $ java -version
    java version "1.6.0_29"
    Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50b)
    Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
    also tested with:
    java version "1.7.0_04-ea"
    Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b16)
    Java HotSpot(TM) 64-Bit Server VM (build 23.0-b17, mixed mode)
    Mac OS X 10.7.3.
    The "Expected Results" are correctly obtained running the same code on MS-Windows.
    Running the jar as sudo works (with write access to /Library/Preferences), as expected.

    Just for fun, try a key without slashes in it (but for example dots if you must use such a long key).
    I say that because a quick Google search points out that Apple stores the preferences in a file hierarchy in the user home folder. I can already see how using keys which look like a file path are going to cause nuclear reactors to meltdown...

  • Java Preferences api jndi / jdbc implementations?

    We have a requirement to save users gui layout preferences (swing client) in a central location (through a j2ee ejb container). the users should be allowed to log into any company workstation, and have the gui client come up with the users preferences restored.
    does anyone know of commercial or open source implementations of the java preferences api that might accomplish this? (hoping not to re-invent...)
    Thanks
    Joe e.

    I am sure this is not a difficult thing to implement, you might actually spend more time looking for open source implementations rather than do it on your own. I am sure you want to save things like window/frame positions, size, colours, look and feel etc. You can simply save this information in a property file/object. Just any idea...

  • Using the Preferences API

    I've never used this API before, so excuse my ignorance. I have a web application that I have been using a properties file to store base app info, such as the backend database, the url for the ldap, etc. This has been working fine, but after reading about the Preferences API, I thought that this might be the better place to store this info. However, I'm having permission problems that I haven't been able to figure out.
    I've got a development copy of everything on a single computer (using Windows XP), Sun One App Server, and Oracle.
    I created a small test class to see if I could load preferences from an xml file. Here's the class
    package portal.common;
    import java.util.*;
    import java.util.prefs.*;
    import java.io.*;
    import java.lang.*;
    public class PortalPreferences{
         Preferences sysPreferencesRoot;
         public void prefs() throws SecurityException{
    sysPreferencesRoot = Preferences.systemRoot();
         public void uploadPrefs(String file) throws IOException, InvalidPreferencesFormatException{
         FileInputStream fis = new FileInputStream(file);
         RuntimePermission rpermiss = new RuntimePermission("preferences.*");
         Preferences.importPreferences(fis);
         public Preferences getPrefs(){
         return sysPreferencesRoot;
    I then used a jsp to instantiate the class and call the uploadPrefs method. The class instantiates without error, but when I try to load the xml file I get the following error:
    access denied (java.lang.RuntimePermission preferences)
    I've never done anything with the security manager before so I'm not sure how to get around this. I tried creating a RuntimePermission object above, but that didn't work.
    If anyone has any ideas, I'd much appreciate it.

    No, actually I've got the Sun One App server loaded on a desktop I built that I'm using as a test box - its not a server. The Sun server is running fine, as is Oracle. The only problem I'm having is figuring out how to use the Preferences API. Maybe this API isn't the right thing to be using, that's why I'm asking for advice as well as how to get around the security issue that I'm having. My goal is to have application level information that can be stored somewhere other than in a database - this is because one of the pieces of app info is the database that's being used. This app will work with any backend. Currently, this info is stored in a properties file inside the WEB-INF directory. This works fine as is. However, my issue with that is that in order to load the properties file, I've got to have a real drive path. This again isn't that much of an issue except when trying to access from a class that doesn't have the servlet context, however, I am looking for an alternative solution to the properties file. The Preferences seemed like a good solution.

  • Preferences API

    Just a small question: I'm using the preferences API to store settings. I just looked around, but I didn't find where these preferences are saved... I mean in what file!
    Can anyone give me a small hint????
    Thnks a lot!

    It is in the users directory. On windows try looking for the env var HOMEPATH at the command line.
    If you print out the system environment in java it is in there as well (although the name is different.)

  • Preferences API storage

    (I'm posting this question here because noone in the beginners forum could answer me)
    I'm using the new (since j2sdk 1.4) Preferences API to store a small number of prefs. I use user nodes (as opposed tot system nodes), and in Windows everything works correct, but linux users get problems with the backingstore (BackingStoreException). The root user does not have this problem.
    The good point about the preferences also seems a bad point: I don't know where the data is stored, so I can't advise on setting a certain directory readable/writable.
    Preferences prefs = Preferences.userNodeForPackage(auteurstool.Auteursomgeving.class);
    boolean someChoice = prefs.getBoolean("some choice", true);And I'm getting these errors:
    13-nov-2002 16:44:59 java.util.prefs.FileSystemPreferences syncWorld
    WARNING: Couldn't flush user
    prefs: java.util.prefs.BackingStoreException: java.lang.ClassCastException:
    org.apache.xerces.dom.DeferredCommentImpl
    13-nov-2002 16:45:00 java.util.prefs.FileSystemPreferences
    checkLockFile0ErrorCode
    WARNING: Could not lock System prefs.Unix error code 135399620.
    13-nov-2002 16:45:00 java.util.prefs.FileSystemPreferences syncWorld
    WARNING: Couldn't flush system
    prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
    java.util.prefs.BackingStoreException: Couldn't get file lock.
    Any suggestions?

    There was an answer in the forum
    http://forum.java.sun.com/thread.jsp?forum=32&thread=325325
    that was also quite interesting.

  • Why do Mac games have higher system preferences compared to Windows games?

    Hello,
    I am wondering why Mac games have higher system preferences compared to Windows games?
    For example "The Movies" game on Mac requires:
    Mac: OSX 10.4 Tiger or later,
    PPC G4 1.67 GHz,
    512MB RAM,
    64MB video card,
    DVD drive (minimum)
    Whilst on Windows:
    PC: Windows 98SE or later
    800 MHz CPU
    256MB RAM
    DirectX 9.0c compatible sound and video card.
    Now anyone can see the amount Windows needs compaired to Mac but why such a huge leap.
    And this isn't only on "The Movies" it's the same with "Sims 2" and "Age of Empires"
    If you know why could you please respond.
    Thanks,
    James

    Hi there vickivoo,
    You may find the troubleshooting steps in the article below helpful.
    Troubleshooting wireless mouse and keyboard issues
    http://support.apple.com/kb/ts3048
    -Griff W. 

  • Java communication api for windows 64 bit

    Hi,
    I need communication api for windows 64 bit. Are these api's in developement?
    Thanks,
    Andrea Todeschini

    If you use version 2.0 of the rxtx library then it provides a complete implementation of the javax.comm package.
    Version 2.1 does not (its in the gnu.io namespace)
    // Try the following url
    http://users.frii.com/jarvi/rxtx/download.html
    matfud

  • About Java Communication API for Windows

    hi
    I'm studying Serial Communication in university.
    I'd like to know the reason why we can't downlaod Java Communication API for Windows.
    I confirmed Comm for Linux and Soralis, but I can't find Comm for Win.
    Please tell me the reason if someone know.

    For no particular reason Sun stopped supporting the windows version
    of that package. I use rxtx which happens to allow for much faster
    communication too.
    The interface is identical to Sun's version, just the package differs: "gnu.io".
    kind regards,
    Jos

  • APEX preferences API

    I've used APEX preferences API call to set/get the user preferences with the following call. But, when I exported the application to a different production system, the user preferences are not available. is it possible to export these user preferences to the new system?. any ideas are appreciated.
    htmldb_util.set_preference(p_preference => 'layout_pref', p_value => :p100_type, p_user => v('APP_USER'));
    thanks for your help,
    Surya

    Hi Surya,
    You can look at extracting your preferences from: FLOWS_030100.WWV_FLOW_PREFERENCES$
    Where FLOWS_030100 is your APEX schema (I'm using 3.1.2)
    You'd need to write a query to isolate the preferences you want then you could create an external table, load them and run a procedure that loops over each preference and re-inserts them using the apex_util.set_preference procedure as you mentioned below.
    I've never tried this before so I highly suggest you test this before doing it.
    Martin
    [http://apex-smb.blogspot.com/]

  • Using Microsoft.UpdateServices.ClientServicing apis on windows operating systems.

    Hi,
    I am willing to use some apis from "Microsoft Update Services", but MSDN says that ,
    `This namespace is used in combination with the Microsoft.UpdateServices.Administration namespace to support updates for clients using operating systems other than Windows (for example, the Windows Mobile operating system).`
    Does that mean that i cannot use the apis on windows Operating systems (eg. Desktop OS)
    Thanks,
    Suraj K.

    There are two namespaces in the WSUS API:
    Microsoft.UpdateServices.Administration - which is used to manage the WSUS server
    Microsoft.UpdateServices.ClientServicing - which (as you've noted) is designed to support custom written agents on systems other than Microsoft Windows -- a facility mostly pointless since the SDP schema used to package updates only supports
    Microsoft Windows executable file formats -- but theoretically it could have been used to support a Windows Mobile 6.x agent, or could even be used to support a Windows RT agent (if only the RT executables could be packaged into a WSUS package).
    If you want to leverage existing Windows systems (i.e. the Desktop OS) talking to existing Microsoft patch management systems (e.g. AU, WU, MU, or WSUS), you'll actually need to write to the
    Windows Update Agent API which is a COM interface.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • Application setting - properties files, user settings - Preferences API

    HI!
    I have 2 rules:
    1. All application settings (e.g. debug level, path to resources - icons, images, path to localization resources) I store in properties files.In other words all information that user CAN NOT change I store use a properties files.
    2. All user settings (e.g. language, skin and so on) I store with Preferences API. In other words all information that user CAN change I store a use Preferences API.
    Is this a good rules?

    a_subscriber wrote:
    HI!
    I have 2 rules:
    1. All application settings (e.g. debug level, path to resources - icons, images, path to localization resources) I store in properties files.In other words all information that user CAN NOT change I store use a properties files.
    2. All user settings (e.g. language, skin and so on) I store with Preferences API. In other words all information that user CAN change I store a use Preferences API.
    Is this a good rules?Sounds good.

  • When I try to edit preferences iTunes for Windows locks up.  I have only one user.  This is true even after a reboot.

    When I try to edit preferences iTunes for Windows locks up.  I have only one user.  This is true even after a reboot.

    Hello MF7642,
    Thank you for contacting Apple Support Communities.
    You can use this article to troubleshoot your issues with iTunes.
    iTunes: Missing folder or incorrect permissions may prevent authorization
    http://support.apple.com/kb/TS1277
    Regards,
    Jeff D.

  • Setting logging.config.class via Preferences API

    The Javadoc for LogManager says:
    In addition, the LogManager uses two optional system properties that allow more control over reading the initial configuration:
    * "java.util.logging.config.class"
    * "java.util.logging.config.file"
    These two properties may be set via the Preferences API, or as command line property definitions to the "java" command, or as system property definitions passed to JNI_CreateJavaVM.
    http://java.sun.com/j2se/1.4/docs/api/java/util/logging/LogManager.html
    So, how can I set the "java.util.logging.config.class" system property via the Preferences API? How can I set any system property via the Preferences API? I think this is a documentation bug, but I would like to know how to do it, otherwise.
    http://java.sun.com/j2se/1.4/docs/api/java/util/prefs/Preferences.html

    I don't know why I couldn't find it when I looked before,
    but it is a filed bug.
    http://developer.java.sun.com/developer/bugParade/bugs/4691587.html
    This help me find a work-around.
    http://developer.java.sun.com/developer/bugParade/bugs/4506094.html

Maybe you are looking for

  • Can't log in to macbook pro

    Whenever I want to log in my 6 months macbook pro. It will log out. I've tried pram etc and it doesn't works. I also entered safe mode and it won't enter. Help me please, this is the video of my mac problem.

  • Zen Xtra computer Softw

    Hello, please help me,i need the software for my new PC of the Zen Xtra that i can't find and put to work. I have my player full of music and i want it to go to the PC but i have no Software and i dont now where to get it.What id the name of the file

  • Camera filters, exporting with the filter..

    I just bought my first iPhone about 2 weeks ago, i like it, but today, I took some photos with the built-in filters and i use dropbox to atutomatically save the photos, BUT my issue is, when exported to dropbox. The photo is not in black/white it is

  • Error message ellements 11

    I am having problems installing ellents 11 I get an error message about shared technologies which I do not understand

  • Can i buy 2 student packages?

    Hi all, I just got a few Questions, I wanted to buy 2 Photoshop CS4 Extended Student Version from Amazon.co.uk. It is directly from Amazon, is that ok? because i read that I should not buy it from Ebay. I basically want to buy one PS CS4 for my XP po