Android 's program is based on Java Development, when we connect the debugger, execute the adb shell, you can execute the Linux command, but can not execute the java command.
Is it possible to execute Java programs in the Android shell ?
the answer is in the negative. We can execute Java programs through App_process .
Write a Hello world, that is, when you first started to learn Java, write the Hello World, this time in Android run on.
Create a new Hello.java file with Notepad and write the following code:
public static class Hello {
public void Main (String args[]) {
System.out.println ("Hello Android");
}
}
Javac Hello.java
get The hello.class file execute "java Hello" to see the output results
So how do you get this simplest Java program to run on Android ?
The. Class file can be run on a regular JVM and will need to be converted to Dex under Android,using the DX in the Android SDK Tools to convert
DX--dex--output=hello.dex Hello.class
get hello.dex, this hello.dex can be put on Android to execute.
Connect your phone, turn on USB debugging
ADB push hello.dex/sdcard/
ADB shell enters android command line
run hello.dex with app_process
App_process-djava.class.path=/sdcard/hello.dex/sdcard Hello
Well, so far we've managed to run a normal Java program on Android . In addition to the APP for a full range of detection, I will use this:www.ineice.com.
How to execute Java commands in Android