title: How do I fix JDK not found error when building Android source?
body: <p>I am trying to build the <a href="http://source.android.com/source/building-running.html" rel="nofollow noreferrer">Android source by the steps provided here.</a> However I have troubles with my JDK. When launching:</p>
  
  
  
  <pre class="lang-bash prettyprint-override"><code>lunch full-eng
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
  /bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
  /bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
  /bin/bash: build/core/find-jdk-tools-jar.sh: Permission denied
  build/core/config.mk:344: *** Error: could not find jdk tools.jar, please install JDK6, which you can download from java.sun.com.  Stop.    
  ** Don't have a product spec for: 'full'
  ** Do you have the right repo manifest?
  </code></pre>
  
  <p>So I tried to install the JDK correctly by the following steps:</p>
  
  <hr>
  
  <p><strong>Step 1</strong></p>
  
  <p>Uninstall everything JAVA related by <a href="https://askubuntu.com/a/185250/112583">following these steps.</a></p>
  
  <p><strong>Step 2</strong></p>
  
  <p>Install correct JAVA by <a href="https://askubuntu.com/a/21133/112583">following these steps</a>. I used the default installer option and version 6, not 7 or 8</p>
  
  <p><strong>Step 3</strong></p>
  
  <p>Here I am simply <a href="https://groups.google.com/d/msg/android-building/6KVsiFxpToA/Qgu0cFsxFcAJ" rel="nofollow noreferrer">following this answer.</a></p>
  
  <pre class="lang-bash prettyprint-override"><code>sudo gedit .bashrc
  </code></pre>
  
  <p>Edit the file at the bottom by adding those lines</p>
  
  <pre class="lang-bash prettyprint-override"><code>JAVA_HOME=/usr/lib/jvm/java-6-oracle
  export JAVA_HOME
  
  # replacing /path/to/androidsdk/ with correct path of course..
  export PATH=${PATH}:/path/to/androidsdk/android-sdk-linux/platform-tools
  
  PATH=$PATH:$JAVA_HOME
  
  # Variable ANDROID_JAVA_HOME
  ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-oracle
  export ANDROID_JAVA_HOME
  
  PATH=$PATH:$ANDROID_JAVA_HOME
  </code></pre>
  
  <p><strong>Step 4</strong> </p>
  
  <p>Test what I've done so far:</p>
  
  <pre class="lang-bash prettyprint-override"><code>...:~$ echo $JAVA_HOME
  /usr/lib/jvm/java-6-oracle
  ...:~$ java -version
  java version "1.6.0_45"
  Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
  Java HotSpot(TM) Server VM (build 20.45-b01, mixed mode)
  ...:~$ which java
  /usr/bin/java
  ...:~$ echo $ANDROID_JAVA_HOME
  /usr/lib/jvm/java-6-oracle
  ...:~$ echo $PATH
  /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-oracle/bin:/usr/lib/jvm/java-6-oracle/db/bin:/usr/lib/jvm/java-6-oracle/jre/bin:/path/to/androidsdk/android-sdk-linux/platform-tools:/usr/lib/jvm/java-6-oracle
  </code></pre>
  
  <p><strong>Step 5</strong></p>
  
  <p>Go in terminal to the Android source folder and enter</p>
  
  <pre class="lang-bash prettyprint-override"><code>source build/envsetup.sh
  </code></pre>
  
  <p>Result:</p>
  
  <pre class="lang-bash prettyprint-override"><code>including device/asus/grouper/vendorsetup.sh
  including device/asus/tilapia/vendorsetup.sh
  including device/generic/armv7-a-neon/vendorsetup.sh
  including device/generic/armv7-a/vendorsetup.sh
  including device/generic/mips/vendorsetup.sh
  including device/generic/x86/vendorsetup.sh
  including device/lge/mako/vendorsetup.sh
  including device/samsung/maguro/vendorsetup.sh
  including device/samsung/manta/vendorsetup.sh
  including device/samsung_slsi/arndale/vendorsetup.sh
  including device/samsung/toroplus/vendorsetup.sh
  including device/samsung/toro/vendorsetup.sh
  including device/ti/panda/vendorsetup.sh
  </code></pre>
  
  <p><strong>Step 6</strong></p>
  
  <p>Go in terminal to the Android source folder and enter</p>
  
  <pre class="lang-bash prettyprint-override"><code>lunch full-eng
  </code></pre>
  
  <p>Result:</p>
  
  <pre class="lang-bash prettyprint-override"><code>.../androidsource$ lunch full-eng
  /bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
  /bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
  /bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
  /bin/bash: build/core/find-jdk-tools-jar.sh: Permission denied
  build/core/config.mk:344: *** Error: could not find jdk tools.jar, please install JDK6, which you can download from java.sun.com.  Stop.
  
  ** Don't have a product spec for: 'full'
  ** Do you have the right repo manifest?
  </code></pre>
  
  <hr>
  
  <p>What did I do wrong? What is missing? What about the "Permission denied"?</p>