Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading the windows registry

807580Aug 19 2009 — edited Aug 19 2009
I initially thought that reading windows registry in java would be a piece of cake and then happily coded the following lines.
package com.ns;

import java.util.prefs.Preferences;

public class RegistryReader {
    public static String KEY;
    public static void main(String [] args) {
        KEY = "HKEY_LOCAL_MACHINE/SOFTWARE/MySQL AB/MySQL Server 5.0/Location";
        Preferences sysPref = Preferences.systemRoot();
        System.out.println(sysPref.get(KEY, "Null"));
    }
}
In the hope of retrieving the path where mysql is installed, I ran the above code, but it prints "Null". When I did a google search I found many third party jars that would aid in reading the registry.

My question is why a very common task like reading windows registry, does not have a simple api in java ? Also if there is no option other than to use third party software, then which one will be a better choice (the one that is reliable and examples of Read/Write registry can be found easily).

regards,
nirvan.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 16 2009
Added on Aug 19 2009
1 comment
216 views