Run the jar file on Android system

Source: Internet
Author: User

Original link: http://blog.sina.com.cn/s/blog_658c8cea0101mdhp.html

The steps are as follows:

1. Package The files into executable jar files (which can be export in eclipse), such as Test.jar;2. Then use DX to compile the class into Dex files, Dex for Android to use the Dalvik virtual machine to recognize the compiled files:go to the android_sdk\build-tools\android-4.3\ directory and execute the following command: (to place the packaged jar file in this directory, specify the directory if not put)DX--dex--output=classes.dex test.jar3. Packaging the generated classes.dex into the Test.jar, you can directly open the jar file with the compression software, the Classes.dex file can be dragged in;4. Import the jar package into your Android device:adb push test.jar/data/local/tmp//Push the PC-side compiled jar package to the/data/local/tmp directory in the Android device5. Set Classpath:Export Classpath=/data/local/tmp/test.jar6. Start the jar:app_process/data/local/tmp svpn.udp.test.TestThere is a main method in//svpn.udp.test.test to this jar file is executed.  Jar Package Directory structure: (Classes.dex and Meta-inf folders at one directory level)


Test.java File:


execution process and output:

Run the jar file on Android system

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.