How to find java runtime in dos on Windows 7


  1. Posts : 3
    Windows 7 RC
       #1

    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 Computer


  2. Posts : 934
    Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
       #2

    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 Computer


  3. Posts : 3
    Windows 7 RC
    Thread Starter
       #3

    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 Computer


  4. Posts : 10,485
    W7 Pro SP1 64bit
       #4

    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 Computer


  5. Posts : 3
    Windows 7 RC
    Thread Starter
       #5

    Excellent, thank you.

    The successful search string is: HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Java Runtime Environment\1.6
      My Computer


  6. Posts : 10,485
    W7 Pro SP1 64bit
       #6

    Great
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
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
All times are GMT -5. The time now is 18:51.
Find Us