title: Gradle finds wrong JAVA_HOME even though it's correctly set
body: <p>When trying to run gradle, I get the following error:</p>
  
  <pre><code># gradle
  
  ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/default-java
  
  Please set the JAVA_HOME variable in your environment to match the
  location of your Java installation.
  </code></pre>
  
  <p>However, when I check the JAVA_HOME variable I get:</p>
  
  <pre><code># echo $JAVA_HOME 
  /usr/lib/jvm/java-7-oracle
  </code></pre>
  
  <p>My JAVA_HOME is defined in .bashrc and I have double checked that it is set as the source.</p>
  
  <p>Running <code>java -version</code> also confirms that JAVA_HOME is set correctly and is on the PATH.</p>
  
  <pre><code># java -version
  java version "1.7.0_51"
  Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
  Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
  </code></pre>
  
  <p>I have also checked that <code>/usr/bin/java</code> symlinks to <code>/etc/alternatives/java</code> which in turn correctly symlinks to <code>/usr/lib/jvm/java-7-oracle/jre/bin/java</code></p>
  
  <p>Additionally I've checked that there are no duplicate JAVA_HOME definitions in <code>.bash_profile</code> or <code>/etc/profile</code>. </p>
  
  <p>So my question is how/why does Gradle find <code>/usr/lib/jvm/default-java</code>, and more importantly how do I point it to the correct directory? </p>
  
  <p>Other programs which require the JDK work fine, so I think its a Gradle issue. I've also tried reinstalling Gradle which made no difference.</p>
  
  <p>I'm running 64bit Xubuntu (Ubuntu 13.10 base)</p>