Running an executable jar in android

后端 未结 5 1234
北海茫月
北海茫月 2021-02-05 18:26

is it possible to run an executable jar file (command line based) in android? one of my friend told me that it is possible to run executables written in C. Is it possible for ja

相关标签:
5条回答
  • 2021-02-05 18:49

    You cannot directly run jar files in android as android runs on Dalvik Virtual Machine, whereas to run jar files you will need Java Runtime Environment which has Java Virtual Machine.

    Note: You will need root access and a file manager with root access:
    But you can run it, for that you have to install an application Jbed.apk and copy lib jbed.so to your system\lib folder. Then you can run jar/jad files from the application on your android device.

    Here's the link to jbed: http://jbed.en.malavida.com/android/

    Read the full post here on XDA Developers: XDA Developers, Run jar/jad on Android

    There are few posts which claims that there are ways to convert jar to apk, I haven't tried it myself: jar to apk If it doesn't works you may need to use an emulator:

    0 讨论(0)
  • 2021-02-05 18:51

    The only problem with running a jar inside Android is the JVM which under Android is a Dalvik VM which cannot run JSE compiled java programs.

    You can however use JBed which runs a whole JSE JVM under Android: http://jbed.en.malavida.com/android/

    0 讨论(0)
  • 2021-02-05 18:52

    is it possible to run an executable jar file (command line based) in android?

    possible, check "adb shell input" shellscript -> "exec app_process"

    shell@flo:/ $ ls -l /system/bin/input                                          
    -rwxr-xr-x root     shell         203 2015-11-10 01:44 input
    

    https://android.googlesource.com/platform/frameworks/base/+/oreo-release/cmds/input/input

    # Script to start "input" on the device, which has a very rudimentary
    # shell.
    #
    base=/system
    export CLASSPATH=$base/framework/input.jar
    exec app_process $base/bin com.android.commands.input.Input "$@"
    
    0 讨论(0)
  • 2021-02-05 18:58

    Android uses the Dalvik VM, whereas you need the Java VM to run a jar-file. So no, you can't run a jar-file on android.

    0 讨论(0)
  • 2021-02-05 19:10

    You can install an app built as an APK through adb:

    adb install my_apk_file.apk
    

    And once inside an adb shell, you can launch an APK application using the am command. See How to start an application using android ADB tools?

    But I don't think there's a way to directly run a jar file the way you can do so on a desktop operating system, because Android doesn't use the standard Java VM.

    I think you would need to embed your .jar file inside a minimal Android application that invokes the jar and prints results to stdout. Then you would build that APK and install/run it as I described above.

    0 讨论(0)
提交回复
热议问题