English Japanese
Scand 
Company Services Products Download News Contact
Company
Personnel
Experience
Portfolio
Workflow

Services
Virtual Office
Fixed bid
F.A.Q.

Products
AWTX
TreeTable
JTree
Vault
JNDI2R
ProSys
Megatester
Urfin
WebHelp

JNDI Service Provider for Windows Registry

Prepare to use

To start working with Windows registry from your Java application WinRegistry.dll file should be discoverable by JVM. You can do it either by adding path to this file to your PATH

set PATH="Directory with WinRegistry.dll";%PATH%
or by copying WinRegistry.dll to your Windows directory or by running java with parameter "java.library.path"
java -cp dist/jndi2r.jar;... -Djava.library.path="Directory with WinRegistry.dll" ...
jndi2r.jar should be added to the classpath. Our service provider is tested to work with JDK1.3 and JDK1.4 and on Windows XP/2000/NT/Me/9x

Embedding in your Java applications

To enable registry operations in your application you should create InitialContext. This can be done as follows:

  Hashtable environment = new Hashtable();
  environment.put("java.naming.factory.initial", 
    "com.scand.jndi.registry.RegistryInitialContextFactory");
  Context c = new InitialContext(environment);
Environment parameters
You can pass the following additional environment parameters:
  • "com.scand.jndi.registry.entryPrefix" is prefix of entries (non-null non-empty string). All entry names passed and returned to the RegistryContext are prefixed with this string. It is used to distinguish key and entry names. To get the default entry for the key use
    c.lookup(c.getEnvironment().get("com.scand.jndi.registry.entryPrefix"));
    If not set the RegistryContext will add the default value to its environment automatically. The default is "". Names in JNDI should be unique but in Windows registry you can have key and value in this key with the same name, to access such keys and values you should set non-empty entryPrefix and prefix all value names with entryPrefix. When entryPrefix id default ("") then you have some restrictions (cannot access key's default value and keys/values with equal names).
  • "com.scand.jndi.registry.initialKey" is the name of the key that will be initially opened (string, can be empty). All operations will be relative to this key. The default is "". For example it can be set to "HKEY_CURRENT_USER\Software\CompanyName\ProductName" or "HKCU\Software\CompanyName\ProductName" (the key should exist).
  • "com.scand.jndi.registry.forceStringSerialization" (string) if equals "true" then String objects will be serialized in the registry (REG_BINARY data type). The default is to write strings as REG_SZ.

Names in Registry are not case sensitive ("key" and "KEY" is the same). For more convenient use the following name aliases are defined:
    "HKEY_CLASSES_ROOT" is aliased to "HKCR"
    "HKEY_CURRENT_CONFIG" is aliased to "HKCC"
    "HKEY_CURRENT_USER" is aliased to "HKCU"
    "HKEY_LOCAL_MACHINE" is aliased to "HKLM"
    "HKEY_USERS" is aliased to "HKU"

Supported registry types

Service provider has support of common registry types: REG_SZ (mapped to java.lang.String), REG_DWORD (mapped to java.lang.Long) and REG_BINARY (mapped to com.scand.jndi.registry.ByteArray). You can also store any serialized java object as REG_BINARY. Support of other types will be in the next release.

Demo version restrictions

In demo version you can create keys/values and read them but you cannot delete them or modify value's content (OperationNotSupported exception will be thrown).

Samples

For more information see com.scand.jndi.registry.demo.simple.Simple.java, com.scand.jndi.registry.demo.RegEdit.java and API documentation. You can run demo RegEdit program as

java -jar RegEdit.jar
Also you can use JNDI Browser that can be downloaded from http://java.sun.com/products/jndi. It should be run as follows:
  java -cp "jndibrowser.jar;jndi2r.jar" examples.browser.Browser 
    "Registry|com.scand.jndi.registry.RegistryInitialContextFactory"
Before running example programs make sure WinRegistry.dll is in your PATH.

API Documentation
API Documentation is included in the distribution. Also it can be found here.
Bug reports or feature requests
If you found bugs or need feature that is not yet implemented, feel free to contact us at info@scand.com.







New demos:
· WebQuicken
· ProSys
· UserMan
· WebDN

These demos use our awt.x components.

Copyright © Scand Ltd. 1999-2010