 <p>The batch script below will print out the existing default JRE. It can be easily modified to find the JDK version installed by replacing the <strong>Java Runtime Environment</strong> with <strong>Java Development Kit</strong>.</p> <pre><code>@echo off setlocal ::- Get the Java Version set KEY="HKLM\SOFTWARE\JavaSoft\Java Runtime Environment" set VALUE=CurrentVersion reg query %KEY% /v %VALUE% 2&gt;nul || ( echo JRE not installed exit /b 1 ) set JRE_VERSION= for /f "tokens=2,*" %%a in ('reg query %KEY% /v %VALUE% ^| findstr %VALUE%') do ( set JRE_VERSION=%%b ) echo JRE VERSION: %JRE_VERSION% ::- Get the JavaHome set KEY="HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\%JRE_VERSION%" set VALUE=JavaHome reg query %KEY% /v %VALUE% 2&gt;nul || ( echo JavaHome not installed exit /b 1 ) set JAVAHOME= for /f "tokens=2,*" %%a in ('reg query %KEY% /v %VALUE% ^| findstr %VALUE%') do ( set JAVAHOME=%%b ) echo JavaHome: %JAVAHOME% endlocal </code></pre>