Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 70563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:45:02+00:00 2026-05-10T19:45:02+00:00

I want to use the java.util.Preferences API but I don’t want my program to

  • 0

I want to use the java.util.Preferences API but I don’t want my program to attempt to read or write to the Windows registry. How would I go about this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:45:02+00:00Added an answer on May 10, 2026 at 7:45 pm

    I trust you have read the read/write to Windows Registry using Java and you then want to have another back-end than the registry when using the java.util.Preferences API

    You could extend the Preference API, like Bernhard or Croft did, as described in this article:

    Because the Preferences API is back-end neutral, you need not care whether the data are stored in files, database tables, or a platform-specific storage such as the Windows Registry.

    Examples of extensions through new Preferences can be seen here.

    That is better, IMO, than to use another API.


    For instance, searching for classes extending java.util.prefs.AbstractPreferences:

    • You can use a preference store backed by an XML file:

    de.unika.ipd.grgen.util.MyPreferences

    import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.prefs.AbstractPreferences; import java.util.prefs.BackingStoreException;  /**  * Own implementation of the Java preferences API, that does not use  * a 'OS backing store' but relies on importing and exporting the  * preferences via xml files.  * Also, If a preference is got, but was not in the tree, it is entered.  */ public class MyPreferences extends AbstractPreferences {      private Map<String, String> prefs = new HashMap<String, String>();     private Map<String, AbstractPreferences> children = new HashMap<String, AbstractPreferences>();    public MyPreferences(MyPreferences parent, String name) {     super(parent, name);   }    /**    * @see java.util.prefs.AbstractPreferences#putSpi(java.lang.String, java.lang.String)    */   protected void putSpi(String key, String value) {     prefs.put(key, value);   } 

    • Or you could store those preferences in an LDAP:

    de.tarent.ldap.prefs.LDAPSystemPreferences

    import java.util.prefs.AbstractPreferences; import java.util.prefs.BackingStoreException;  import javax.naming.NamingException; import javax.naming.directory.Attributes;  import de.tarent.ldap.LDAPException; import de.tarent.ldap.LDAPManager;  /**  * @author kirchner  *   * Preferences im LDAP  */ public class LDAPSystemPreferences extends AbstractPreferences {     LDAPManager     ldm         = null;     Properties      properties  = new Properties();     //Map für key/value der Preferences     Map             cache       = new HashMap();     //Map für timestamp der Preferences     Map             timestamp   = new HashMap();     private Boolean deleted     = Boolean.FALSE; 

    • Or you can use a simple property file:

    com.adito.boot.PropertyPreferences:

    import java.util.prefs.AbstractPreferences; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences;  import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;   /**  * A simple implementation for the preferences API. That stores preferences  * in propery files. We do not have to worry about sharing the preferencese   * with other JVM instance so there is no need for any kind of synchronising  * or locking.  */ public class PropertyPreferences extends AbstractPreferences { 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 151k
  • Answers 151k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Look at the functions date() and strtotime(): echo date('Y'); echo… May 12, 2026 at 9:57 am
  • Editorial Team
    Editorial Team added an answer There is a great category on NSString/NSAttributedString by Jerry Krinock… May 12, 2026 at 9:57 am
  • Editorial Team
    Editorial Team added an answer You need to expose the properties you want to modify… May 12, 2026 at 9:57 am

Related Questions

I want to use the java.util.Preferences API but I don't want my program to
So, I have a situation where I need to pass in three values into
Let's assume we've got the following Java code: public class Maintainer { private Map<Enum,
I need to store some simple properties in a file and access them from
I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here's the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.