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 java too? I will run the tool through adb shell.
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 .
Install the lastest Java SDK. Make sure to set your JAVA_HOME variable after installing and also include %JAVA_HOME%\bin in your PATH environment variable. It is installed correctly when you can go to a command prompt and type java -version and get a valid response (something other than Bad command or File Name).
A JAR (Java Archive) is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file to distribute application software or libraries on the Java platform.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With