I found some information from this link:
http://davanum.wordpress.com/2007/12/04/command-line-java-on-dalvikvm/.
I have tried to do that with android apps but failed. The emulator
just auto rebooted.
the reason i want to do this is because i want to debug JNI functions.
although i can use gdb to attach the already running process and set
breakpoints, some other problems always happens when doing remote
debug with gdb in eclipse. i have found that when run the process
directly with gdbserver then everything goes well. so i want to know
how to run android java apps with dalvikvm directly so maybe i can
debug jni native codes with eclipse then. and i think it must be a
possible thing.
anybody knows? please help me. thanks.
sorry for post it here because i have posted it in group android
developers. but i think this is a cross subject problem :-)
Here's a sketch of what you'll need to do:
1. Compile your classes as you would for a Java VM. You'll need at
least one class with a main method.
2. Use the dx tool to create a dalvikvm executable. This is usually
a .jar file with a single classes.dex file inside, rather than the
several .class files.
3. Copy the dalvik executable to your device. With adb, this is "adb
push mydexfile.jar /data/mydexfile.jar"
4. Run the VM: "adb shell dalvikvm -classpath /data/mydexfile.jar
com.mycompany.MyMainClass"
Hope this helps!
Cheers,
Jesse
To be even more specific, you can't use any of the Android framework
classes. Some of the utility classes might work, but without the full
app process init sequence most things won't work.
Here's a quick tutorial on executing a "hello, world" program (dalvik/
docs/hello-world.html in the source tree):
http://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=docs/hello-world.html;hb=HEAD
It also describes attaching a Java-language debugger. You can't
really test your full app this way, but you can write something that
drives your JNI code, which may be good enough for your purposes.