How to execute java commands in android
Android programs are developed based on java. When we connect to the debugger and execute adb shell, we can execute linux commands, but cannot execute java commands. So can't java programs be executed in the android shell. The answer is no. We can use app_process to execute java programs. Write a hello world, that is, the hello world written at the beginning of learning java. This time, it will be run on android. Use NotePad to create hello. java file, write the following code: public static class hello {public void main (String args []) {System. out. println ("Hello Android") ;}} javac hello. java get hello. if the class file runs "java hello" and the output result is displayed, how can this simplest java program be run on android .. The class file can be run on a common jvm. To put it under android, you also need to convert it to dex. You need to use the dx tool in android sdk to convert dx -- dex -- output = hello. dex hello. class to get hello. dex, this hello. dex can be executed on android. Connect to the mobile phone, Enable usb debugging adb push hello. dex/sdcard/adb shell enter the android command line and use app_process to run hello. dexapp_process-Djava. class. path =/sdcard/hello. dex/sdcard hello, so far we have successfully run a common java program on android.