I am trying to execute Java program in Android. Used the link How to execute the dex file in android with command? as reference. My question is, can I run the Java program on the emulator from eclipse? When I tried adb install HelloWorld.apk(in command prompt), it says AndroidManifest.xml is missing. Do I have an option to do it? Please help.
Asked
Active
Viewed 4,637 times
5
-
1android dont have a jvm to run java byte code it uses a differnt one DVM and dex code is run on that you cant run a java prog on android just like that – Athul Harikumar Sep 05 '12 at 11:23
-
Is there any other alternative to do this? – user1637909 Sep 05 '12 at 11:29
-
no way you have to create a native android application to run it on android – Athul Harikumar Sep 05 '12 at 11:32
-
Are you wanting to run a command-line based java tool? Or an actual Android application? – JesusFreke Sep 07 '12 at 01:47
1 Answers
9
Android uses the Dalvik VM, instead of the Java VM. Due to this, you cannot execute standard java programs on an Android device. Additionally, Android programs are supported by various XML files like the Android Manifest, layout files, resource files etc. The Android Manifest is especially important, as it contains information on which part of the app can be launched, which is a service or a receiver, what permissions the apps needs, what hardware and software features the app needs, which version of Android is compatible with it etc.
So in short: No, you cannot execute normal java programs on Android.

Raghav Sood
- 81,899
- 22
- 187
- 195
-
Sure you can. Most command-line based java tools should work fine, after you run them through dx. – JesusFreke Sep 07 '12 at 01:43
-
I want to run Java bytecode program in an actual Android application. @JesusFreke – user1637909 Sep 07 '12 at 09:52
-
Basically, there is no way to run raw JVM bytecode on Android. You *must* convert it to dalvik bytecode first. – Raghav Sood Sep 07 '12 at 10:13
-
Ok thanks! 1 more thing to clarify. I used http://jokar-johnk.blogspot.fi/2011/02/how-to-make-android-app-with-sl4a.html link to run Python in Android. Can u please let me know how to create a widget in Python? @RaghavSood – user1637909 Sep 07 '12 at 10:54
-
That has nothing to do with your current question. Open a new question for that. – Raghav Sood Sep 07 '12 at 13:39