title: What is the correct target for the JAVA_HOME environment variable for a Linux OpenJDK Debian-based distribution?
body: <p>In Windows, <code>JAVA_HOME</code> must point to the JDK installation folder (so that <code>JAVA_HOME/bin</code> contains all executables and <code>JAVA_HOME/libs</code> contains all default <code>jar</code> libraries).</p>
  
  <p>If I download Sun's JDK bundle and installs it in Linux, it is the same procedure.</p>
  
  <p>However, I need to use Kubuntu's default OpenJDK package. The problem is that all executables are placed in <code>/usr/bin</code>. But the jars are placed in <code>/usr/share/java</code>. Since they are not under the same <code>JAVA_HOME</code> folder I'm having trouble with Grails and maybe there will be trouble with other applications that expect the standard Java structure.</p>
  
  <ol>
  <li><p>If I use:</p>
  
  <pre><code>JAVA_HOME=/usr
  </code></pre>
  
  <p>All applications and scripts that want to use any Java executable can use the standard procedure <code>call $JAVA_HOME/bin/executable</code>. However, since the jars are in a different place, they are not always found (example: in grails I'm getting <code>ClassDefNotFound</code> for <code>native2ascii</code>).</p></li>
  <li><p>On the other hand, if I use:</p>
  
  <pre><code>JAVA_HOME=/usr/share/java
  </code></pre>
  
  <p>None of the Java executables (<code>java</code>, <code>javac</code>, etc.) can be found.</p></li>
  </ol>
  
  <p>So, what is the correct way of handling the <code>JAVA_HOME</code> variable in a Debian-based Linux?</p>
  
  <p>Thanks for your help,
  Luis</p>