Java has always been marketed as “write once, run anywhere.” The capability has largely been
made possible by the Java Platform, the foundation of which is the Java Virtual Machine (JVM).
While Google has selected Java as the language for developing Android applications, it has
chosen to abandon both JME and the JVM in favor of an alternative deployment target, the Dalvik
virtual machine.
every Android application runs in its own process, with its own instance of the Dalvik
virtual machine. Dalvik has been written so that a device can run multiple VMs ef?ciently.
The Dalvik VM executes ?les in the Dalvik Executable (.dex) format which is optimized for
minimal memory footprint. The VM is register-based, and runs classes compiled by a Java
language compiler that have been transformed into the .dex format by the included "dx"
tool.
The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and
low-level memory management
In standard Java environments, Java source code is compiled into Java bytecode, which is stored
within .class ?les. The .class ?les are read by the JVM at runtime.
On the Android platform, Java source code is still compiled into .class ?les. But after .class ?les
are generated, the “dx” tool is used to convert the .class ?les into a .dex, or Dalvik Executable, ?le.
Whereas a .class ?le contains only one class, a .dex ?le contains multiple classes. It is the .dex ?le
that is executed on the Dalvik VM.
The .dex ?le has been optimized for memory usage and the design is primarily driven by
sharing of data.