gpt4 book ai didi

java - 如何通过java程序创建注册表项?

转载 作者:搜寻专家 更新时间:2023-11-01 01:19:40 25 4
gpt4 key购买 nike

我想通过 java 程序创建注册表项以在启动时添加 jar 文件。

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

但是我得到了错误:

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)

我该怎么做?
谢谢

最佳答案

来自 the Javadoc :

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

你不会有机会使用 win 64 操作系统吗?

如果没有,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

关于java - 如何通过java程序创建注册表项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2627446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com