The environment

win10 + android studio

Start by preparing a class

public class HelloWorld { public static void main(String... args) { System.out.print("Hello world"); }}

Compile the HelloWorld. Java

Execute the following code to generate the HelloWorld.Class

Javac-source 1.7-target

Dex, F:/Android/SDK is the SDK directory for Android Studio

F:/Android/SDK/build-tools/27.0.3/dx --dex --output classes. Dex helloworld.class

Push HelloWorld.dex to the device and execute

adb push classes.dex /data/local/tmp/
adb shell CLASSPATH=/data/local/tmp/classes.dex app_process / HelloWorld

Execute the HelloWorld class within APK

Install the APK to the device to get the CLASSPATH

The adb shell PM path com. Sjie. The test output: package: / data/app/com. Sjie. Test - PNXoSOiRofkBI_0H1NS_yA = = / base. The apk

Perform the HelloWorld

adb shell
export CLASSPATH=/data/app/com.sjie.yahfatest-PNXoSOiRofkBI_0H1NS_yA==/base.apk
exec app_process /system/bin com.sjie.yahfatest.HelloWorld


adb shell CLASSPATH=/data/app/com.sjie.yahfatest-PNXoSOiRofkBI_0H1NS_yA==/base.apk app_process / com.sjie.yahfatest.HelloWorld