How to execute java commands in android

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.