title: Finding JDK path and storing it as a string in Java
body: <p>I would like to find the JDK path on multiple operating systems.</p>
  
  <p>I'm not sure if there's a nice way of doing this as I've been trying and failing.</p>
  
  <p>For Windows it would be something like this - <code>C:\Program Files\Java\jdk1.7.0_07</code> or this 
  <code>C:\Program Files(x86)\Java\jdk1.7.0_07</code></p>
  
  <p>For Linux it would be something like this - <code>/usr/java/jdk1.7.0_07</code></p>
  
  <p>I want this to work for any version of JDK installed, so the numbers after Java\jdk are irrelevant.</p>
  
  <p>I will be using <code>System.setProperty("java.home", path);</code></p>
  
  <p>Basically, what I am looking to do is when I run my program, set java.home to be the JDK installed on the current machine, but getting the JDK path is proving very difficult, any solutions?</p>