Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does android system include JVM?

I know android system include the Dalvik virtual machine(DVM) But i didn't understand if android system include JVM also Or DVM is a replacement for JVM? Thanks

like image 903
user1019872 Avatar asked Feb 22 '15 21:02

user1019872


People also ask

Where is JVM used in Android?

Virtual Machine enables the same code to be run on multiple platform independent of the underlying hardware. For example: the JVM runs java bytecode and produces same output on multiple platforms. Android also makes use of a virtual machine to run the APK files.

Why JVM is not use in Android?

Though JVM is free, it was under GPL license, which is not good for Android as most the Android is under Apache license. JVM was designed for desktops and it is too heavy for embedded devices.

What is JVM in Android programming?

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode.

What is JVM and DVM in Android?

Java Virtual Machines are used to run Java bytecode. On the other hand, DVM are used to run native code. JVM are implemented to provide portability of applications that can run on any machines that have JVM installed while DVM are implemented to provide maximum performance. Dynamic Virtual Machine (DVM)


2 Answers

Programs are commonly written in Java and compiled to bytecode for the Java virtual machine, which is then translated to Dalvik bytecode and stored in .dex (Dalvik EXecutable) and .odex (Optimized Dalvik EXecutable) files.

In short, programs are compiled into JVM bytecode, which is then interpreted into DVM bytecode. Instead of running the compiled Java code, Dalvik compiles it and then translates that code into it's own code. It in some way is a replacement for the JVM.

An alternative runtime environment called Android Runtime (ART) was included in Android 4.4 "KitKat" as a technology preview. ART replaces Dalvik entirely in Android 5.0 "Lollipop".

ART, the Android Runtime, replaced Dalvik in Android 5.0. ART still uses the same .dex files, but they are instead translated into .elf(Executable and Linkable Format) files. This is another replacement for the JVM, as Java code is compiled into JVM bytecode, then translated into DVM bytecode, then translated into an ELF file and executed.

@Chris Thompson does a great job explaining DVM bytecode on Understanding disassembly of Dalvik code.

Sources: Wikipedia / Friends / Experiences

like image 162
jado Avatar answered Sep 23 '22 07:09

jado


But i didn't understand if android system include JVM

No.

Or DVM is a replacement for JVM?

The Dalvik virtual machine is for executing Android applications compiled to Dalvik bytecode. The Java virtual machine is for executing Java applications compiled to Java bytecode. Whether you consider one to be a replacement for the other is up to you.

like image 34
CommonsWare Avatar answered Sep 21 '22 07:09

CommonsWare