Windows 7 Forums


Windows 7: How to find java runtime in dos on Windows 7

10 Mar 2012   #1

Windows 7 RC
 
 
How to find java runtime in dos on Windows 7

I have been unsuccessful in finding the right DOS commands to achieve this and would appreciate some help.

This is an extract from my registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6]
"JavaHome"="G:\\Program Files (x86)\\Java\\jre6"

Not sure why it is showing the double backslash...

I've tried various commands (in BATch files), such as the following, without success:

- - - -
@echo off
set KeyName=SOFTWARE\JavaSoft\Java Runtime Environment\1.6
REM set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
set Cmd=reg query "%KeyName%" /s
for /f "tokens=2*" %%i in ('%Cmd% ^| find "JavaHome"') do set JAVA_HOME=%%j



set JAVA_HOME
pause
- - - -

Any help will be appreciated.

I know this can be set manually, but this is not what is needed.
My System SpecsSystem Spec

12 Mar 2012   #2

Windows 8; Windows 7 x86 (Dec2008-Jan2013)
 
 

You have missed one detail:
Code:
@echo off 
set KeyName=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.6 
REM set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment 
set Cmd=reg query "%KeyName%" /s 
for /f "tokens=2*" %%i in ('%Cmd% ^| find "JavaHome"') do set JAVA_HOME=%%j 
set JAVA_HOME 
pause
My System SpecsSystem Spec
13 Mar 2012   #3

Windows 7 RC
 
 

Thank you for responding. I should have mentioned that your suggestion was one of the variations I had tried - sorry.

Here is a screen print showing the result of two different tests.



Thanks again for trying to help
My System SpecsSystem Spec
.


13 Mar 2012   #4

W7 Pro SP1 64bit
 
 

Neutron16's change worked for me. Should you be using HKLM64? I only have a 32bit VM to test in right now.

How to find java runtime in dos on Windows 7-reg.jpg

Code:
cd\
set KeyName=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.6
set Cmd=reg query "%KeyName%" /s
for /f "tokens=2*" %%i in ('%Cmd% ^| find "JavaHome"') do set JAVA_HOME=%%j
set JAVA_HOME
pause
My System SpecsSystem Spec
14 Mar 2012   #5

Windows 7 RC
 
 

Excellent, thank you.

The successful search string is: HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Java Runtime Environment\1.6
My System SpecsSystem Spec
14 Mar 2012   #6

W7 Pro SP1 64bit
 
 

Great :-)
My System SpecsSystem Spec
Reply

 How to find java runtime in dos on Windows 7 problems?



Thread Tools



Similar help and support threads for: How to find java runtime in dos on Windows 7
Thread Forum
Java Runtime Environment 7.05 Released Software
Java Runtime Environment 7.04 Released Software
Java Runtime Enivronment Browsers & Mail
Java Runtime 6.0 Software
Java SE Runtime Environment (JRE 6 Update 17) Software


All times are GMT -5. The time now is 11:02 PM.



Windows 7 Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows 7" and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd