title: Find absolute java.exe path programmatically from java code
body: <p>If I have a java jar or class file which is launched by the user (assuming java path is set in environment variables), so how can i from within the code, figure out absolute path of java.exe/javaw.exe from which this file is being launched.  </p>
  
  <p>Like on ubuntu we can run: <code>% which java</code> and it shows the path.  </p>
  
  <p>However on windows, if i check <code>System.getenv()</code> it may happen that there are multiple path's found e.g for old or new version. If through cmd line, I run <code>java -version</code> it does not show the path.  </p>
  
  <p>Can you tell me either through pure java or command line on windows how is it possible to find out the location of javaw.exe?</p>