title: Android: javac vs Dalvik
body: <p>My understanding is that Google didn't like Oracle's licensing policy for using the JRE in Java ME so it just rewrote
  it using its own JVM specification that <em>mimics</em> the JRE but behaves a little bit differently, especially when it comes
  to making things more efficient and more secure.</p>
  
  <p>So, if my understanding is correct, it means that when <code>javac</code> is ran on some Java source code and compiled into "binary"
  byetcode, a compliant JVM will interpret that bytecode different than Dalvik will (in some cases). This is the inherent
  difference between Dalvik and other (compliant) JVMs.</p>
  
  <p>If anything I have said so far is incorrect, please begin by correcting me!</p>
  
  <p>Now, if Android came with its own compiler (which it might), and compiled Java source in a different (Dalvik-compliant)
  manner than <code>javac</code>, then I could understand how some code (not compiled with the Android SDK) would not run on an
  Android device:</p>
  
  <pre><code>MySource.java --&gt; javac --&gt; MySource.class (JRE-compliant) --&gt; JVM --&gt; running Java app
  MySource.java --&gt; android-compiler --&gt; MySource.class (Dalvik-compliant) --&gt; Dalvik JVM --&gt; running Android app
  </code></pre>
  
  <p>However, it looks like you use <code>javac</code> to compile Android apps!?!? So it looks like we have this:</p>
  
  <pre><code>MySource.java --&gt; javac --&gt; MySource.class (JRE-compliant) --&gt; JVM --&gt; running Java app
  MySource.java --&gt; javac --&gt; MySource.class (JRE-compliant) --&gt; Dalvik JVM --&gt; running Android app (???)
  </code></pre>
  
  <p>If <code>javac</code> is used to compile all sources into bytecode, then why is it that Dalvik can't run some types
  of Java code?</p>
  
  <p>I asked a very similar question yesterday and although it was technically answered (after re-reading my question
  I see I was simply not specific enough) no one was able to explain what it is that's inherent to Dalvik that
  makes it impossible to run Java code from projects like Google Guice or Apache Camel. I was told that in order to get Camel to run on Dalvik, that I would have to get Camel's source and then it would have to be "built with the Android SDK", but I couldn't get clarity on what that meant or implied.</p>
  
  <p>With Camel, for instance, you have this (simplified):</p>
  
  <pre><code>RouteBuilder.java --&gt; javac --&gt; RouteBuilder.class --&gt; jartool --&gt; camel-context-2.9.jar --&gt; JVM --&gt; running Camel ESB
  RouteBuilder.java --&gt; javac --&gt; RouteBuilder.class --&gt; jartool --&gt; camel-context-2.9.jar --&gt; Dalvik JVM --&gt; doesn't work !!! (???)
  </code></pre>
  
  <p>Clearly, something is happening inside the Dalvik JVM that prevents it from running certain types of Java code.
  <strong>I'm trying to understand what types of Java code will not run when "fed" into the Dalvik JVM.</strong></p>
  
  <p><strong>Edit:</strong> In before "<em>but Camel 3.0 will run on Android!</em>" I know - not my question!</p>