This article is only for pure Java Project execution interpretation, generally in the PC platform as a jar package exists, on the Android platform in the form of Dex package.
Java is a high-level programming language, and Java programs need to run in a specific virtual machine, and the virtual machine translates Java bytecode into corresponding machine instructions for execution. Different platforms have different virtual machines that correspond to their respective machine instructions. The PC side typically uses the JVM virtual machine and the Android side uses the Dalvik virtual machine.
You need to configure the environment:
- Java JDK Development environment
- IDEA Development tools
- Android SDK Development Environment
- Android build-tools environment variable (optionally specify a version)
JVM in Dalvik
The JVM:PC platform Java Virtual Machine provides the execution environment for Java application execution.
The Dalvik:android platform Java Virtual Machine provides a runtime environment for Java applications, distinguished from JVM bytecode.
Java program execution PC execute idea configuration executable jar package
1. Create a Java project
2, Idea choice file->project structure---artifacts ()-click + after select Jar, from module with dependencies
3. Configure the compiled module, specify the entry class (must overwrite the Main method)
4. Modify the directory for Meta-inf/mainfest. MF: Remove the main (for example: E:\CloudFiles\project\TestJar\testlib\src\META-INF\MANIFEST. MF)
Package and Execute
1, select Build, build artifacts, select Build to start hitting Jar package, jar package output path is \out\artifacts\modulename
2, run the jar package will be executed through the specified Java class, execute the command as follows:
java -jar
Android execution
Executing Java programs on the Android platform relies on the Dalvik virtual machine, so you need to convert the jar package to the corresponding bytecode file, as follows:
1. Generate Java jar package with PC execution
3. Java jar package to Dex package, execute the following command
4. Connect the Android phone and push the Dex execution program into the Android device path:
adb push E:\test.dex /data/local/tmp/
5, through the Dalvik command to execute the DEX program, the program through the specified entry Java class Main method to start execution
dalvikvm -cp /data/local/tmp/test.dex com.qihoo.trace.TestMain
Android system executes Java JAR Program--Dalvik running Dex Java Project