Im using the innosetup to install my program java, the installer will generated the key run. I want to get the path of installation
Line of innosetup:
Ro
I don't know if there is a built-in registry key for the installed program folder, but you can always create your own. You have the installer script create the registry key during installation, using {app}
as the placeholder for the registry value.
Reading from any arbitrary key in the Windows registry from Java can be done with some trickery, but to keep to standard JDK classes and documented features, it's best to use the standard Preferences
interface. Preferences under the system root get placed as keys under HKLM\Software\JavaSoft\Prefs\. Bear in mind there is some strangeness with upper-case letters - each uppercase letter is prefixed with a slash, so keep the name of the key lowercase. e.g. installdir
rather than InstallDir
.
In summary: to find the installation directory, add a registry key under Software\Java\Prefs to the installer script and you can use the system root of java.util.Preferences to retrieve the value at runtime.