Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create registry key through java program?

Tags:

java

registry

I want to create registry key through java program to add the jar file in the start up.

RegistryKey r=new RegistryKey(RootKey.HKEY_CURRENT_USER,"Software/Microsoft/Windows/CurrentVersion/Run");
        r.createSubkey("sample");

But i got the error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: ca.beq.util.win32.registry.RegistryKey.testInitialized()V
        at ca.beq.util.win32.registry.RegistryKey.testInitialized(Native Method)

How can i do that?
Thanks

like image 495
Arivu2020 Avatar asked Dec 13 '22 22:12

Arivu2020


1 Answers

From the Javadoc:

Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.

You wouldn't be on a win 64 OS by any chance?

If not, the manual for jreg mentions:

jRegistryKey is a JNI library. To use jRegistryKey, the following files are required:

  • jRegistryKey.jar
  • jRegistryKey.dll

jRegistryKey.jar is the Java™ Archive (JAR) file containing the packaged Java™ class files, whereas jRegistryKey.dll is a Windows® dyanmically linked library (DLL) that contains the native (C/C++) code required to access the registry.

jRegistryKey.jar must be included in the CLASSPATH available to the Java™ Virtual Machine (JVM);

jRegistryKey.dll must be located in a directory included in the Windows® PATH environment variable or java.lang.UnsatisfiedLinkError's will be generated

like image 127
VonC Avatar answered Dec 31 '22 06:12

VonC