I can go to regedit in windows then go to edit->find and type in the key I want to find in my computer (in my case Maxima) and locate the required key (of maxima) (in my case it is in "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Maxima-5.17.1_is1") but I need to do this dynamically in java and find the current version of maxima installed and its directory location in windows. I have no idea how to proceed.
I tried to use the methods stated here: read/write to Windows Registry using Java, but to use these methods I need to know the key. How can I find the key dynamically in java? Or is there any other ways to find the version and directory location of a software in windows using java?
I would avoid forcing access to private methods, because:
If you use reg.exe, your code is guaranteed to work in all versions of Java, at least for as long as Microsoft includes reg.exe with Windows:
I will use this class for your answer. Because it is written in pure java code.
WinRegistry
class from here.Here is the code to help you :
Now this
key
value will beMaxima-5.17.1_is1
(if present otherwisejava.util.NoSuchElementException
will be thrown). And you can use it to get any Value.