I try to read a value from Windows Registry. This code works good, when I run it in Intellij Idea.
public static String getInstallLocationValue() {
String value = WinRegistry.getString(
WinRegistry.HKEY_LOCAL_MACHINE,
"SOFTWARE\\" + ApplicationConstants.APP_NAME + "\\",
"InstallLocation");
System.out.println("Windows Distribution = " + value);
return value;
}
But it crashes when I run it from jar file:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/deploy/util/WinRegistry at com.doos.utils.RegistryManager.getInstallLocationValue(RegistryManager.java:10) at com.doos.core.Main.main(Main.java:51)
Caused by: java.lang.ClassNotFoundException: com.sun.deploy.util.WinRegistry
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Do you have any ideas, how to fix this?
I did not solve the problem with WinRegistry, instead I used the Advapi32Util class from the JNA library.