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 that Hello, this time to run on Android.
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 tool in the Android SDK
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.
You know this is an Android code written in Notepad, it's unheard of! Let's show off as a little buddy.
For more information, please follow my public number: Zhaojietec
How to execute Java commands in the--android of the journey through