How can I get jre - for example jre7 (it could be also jre6 and so on) - folder path using C++ in Windows 32 and 64bit? Simple question - but hard to find working solution/code..
Asked
Active
Viewed 743 times
2
-
You could probably dig in the registry to find the default opener for .jar-files or something like that. – dutt Mar 21 '14 at 19:12
-
Yes, I found [here](http://www.rgagnon.com/javadetails/java-0525.html), but I not like the solution - new files must be created, then deleted. Registries are OK, but how to analyze them effectively? I need some working C++ source code. Trying to find out now. – Ernestas Gruodis Mar 21 '14 at 20:32
-
http://stackoverflow.com/questions/3167828/get-location-of-java-home-in-c and http://stackoverflow.com/questions/6808541/finding-a-jre-from-c-windows – deviantfan Mar 21 '14 at 20:44
-
Now you know where to look, all you need now is a way to read the registry. For example; http://stackoverflow.com/questions/34065/how-to-read-a-value-from-the-windows-registry – dutt Mar 21 '14 at 20:51
1 Answers
0
You have multiple options :
- Search the registries (link already given in comments)
- Use some cmd command from c++ then parse the output (check JRE installation directory in Windows )
- parse the PATH env variable (usually JAVA_HOME is pointing to the JDK , however, if JRE is needed , the user might add the /jre/bin in it's PATH variable.
Regarding 32 and 64 bit, in order to properly check if a java machine is installed (meaning the situation where a 32 bit java machine is installed on a 64 bit windows) you might want to check the Wow6432Node registry as well).

Community
- 1
- 1

MichaelCMS
- 4,703
- 2
- 23
- 29