Forums Register Login

Working with registry

+Pie Number of slices to send: Send
Hi Friends,
is there a pure java based solution for accessing the windows registry. I read in the Core Java(Sun Publications), that because the registry is a pure windows based concept(component), java don't have any api's for accessing windows registry and you need to go to JNI. Is that so?. Any suggetions are welcome.
Thanks in advance
+Pie Number of slices to send: Send
Yes, that is so. The Java API is platform independent, so you will not find platform specific things in there, for example to access the Windows registry.

You could program your own solution using JNI (create some C or C++ code that calls the Win32 API to access the registry), or use one of the libraries available on Internet, for example: http://sourceforge.net/projects/jregistrykey
+Pie Number of slices to send: Send
Microsoft has java classes for reading the registry. They're somewhere on my Win98 system in a classes.zip file. That file was created by running a utility program on windows.
+Pie Number of slices to send: Send
Actually, it's not so. Starting with Java 1.4, the java.util.prefs package does provide access to the Windows registry. On other platforms (Unix et al.), it is mapped to files.
+Pie Number of slices to send: Send
 

Originally posted by Ulf Dittmer:
Actually, it's not so. Starting with Java 1.4, the java.util.prefs package does provide access to the Windows registry. On other platforms (Unix et al.), it is mapped to files.



Well...yes and no. In the current implementation on windows, the Preferences is mapped to a node in the Registry, but that's not guaranteed. Also, you have NO access to any registry keys other than the ones under :

HK_LOCAL_MACHINE\JavaSoft\Prefs
HK_CURRENT_USER\JavaSoft\Prefs

So it's not really Registry access.
+Pie Number of slices to send: Send
Surely there's a command-line registry-twiddlin' doohickey out there somewhere (there might even be one bundled with Winders.) An alternative to JNI would be to use Runtime.exec() to launch that program.
+Pie Number of slices to send: Send
 

Originally posted by Ernest Friedman-Hill:
Surely there's a command-line registry-twiddlin' doohickey out there somewhere (there might even be one bundled with Winders.)



reg

However, you still can only change what the user has rights to - so there still is a good possibility that it won't work for a "limited account". But you could generate a .bat file and then use runas. This could also be of interest.

PS: If you have a whole slew of changes to make, you could generate a reg file and run
regedit /s filename.reg
See Distributing Registry Changes
or generate an inf file and run
rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 filename.inf
See MS Windows NT Workstation Deployment Guide - Automating Windows NT Setup
[ September 30, 2005: Message edited by: Peer Reynders ]
+Pie Number of slices to send: Send
Here's a java program I wrote a couple of years ago that reads registry entries:

Your mother was a hamster and your father was a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2597 times.
Similar Threads
finding all installed program in windows using java swing?
Registry
Any API for accessing System Registry
Accessing Registry
Mock Test Practice
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:53:08.