Alex Rivera | Logout

Read/write to Windows registry using Java

Asked 2008-09-15T12:16:55.093
344

How is it possible to read/write to the Windows registry using Java?

Edit
Report

2 Answers

4

My previous edit to @David's answer was rejected. Here is some useful information about it.

This "magic" works because Sun implements the Preferences class for Windows as part of JDK, but it is package private. Parts of the implementation use JNI.

The implementation is selected at runtime using a factory method here: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/java/util/prefs/Preferences.java#Preferences.0factory

The real question: Why doesn't OpenJDK expose this API to public?

answered 2013-06-26T01:48:32.210
2

Yet another library...

https://code.google.com/p/java-registry/

This one launches reg.exe under the covers, reading/writing to temporary files. I didn't end up using it, but it looks like a pretty comprehensive implementation. If I did use it, I might dive in and add some better management of the child processes.

answered 2013-03-28T18:05:23.393

Your Answer