So, for a project I am working on, I need to find out where a javaw.exe
is located on a user's machine. How do I do that? Assuming that user is on Windows machine
The method that I used is limited to English versions of Windows only.
I looked for where the OS is installed, locate the Program Files
directory, locate Java
, jdk
directory, bin
, then javaw.exe
. I know this will not work on non-English versions of Windows.
What is the human-language-independent way to do this ?
For the sake of completeness, let me mention that there are some places (on a Windows PC) to look for
javaw.exe
in case it is not found in the path: (Still Reimeus' suggestion should be your first attempt.)1.
Java usually stores it's location in Registry, under the following key:
HKLM\Software\JavaSoft\Java Runtime Environement\<CurrentVersion>\JavaHome
2.
Newer versions of JRE/JDK, seem to also place a copy of
javaw.exe
in 'C:\Windows\System32', so one might want to check there too (although chances are, if it is there, it will be found in the path as well).3.
Of course there are the "usual" install locations:
[Note, that for older versions of Windows (XP, Vista(?)), this will only help on english versions of the OS. Fortunately, on later version of Windows "Program Files" will point to the directory regardless of its "display name" (which is language-specific).]
A little while back, I wrote this piece of code to check for
javaw.exe
in the aforementioned places. Maybe someone finds it useful:To find "javaw.exe" in windows I would use (using batch)
It should work in Windows XP and Seven, for JRE 1.6 and 1.7. Should catch the latest installed version.
Try this
Open a cmd shell,
It worked to me: