P basak
P basak

Reputation: 5004

Running an executable jar in android

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.

Upvotes: 20

Views: 89878

Answers (9)

Redmi9 Prime
Redmi9 Prime

Reputation: 1

I am releasing a magisk module for installing jdk natively(Without modifying system or kernal ) in Android at my Github

Upvotes: 0

AmirHosein
AmirHosein

Reputation: 1

I am glad that you asked this question. This was a question for me in the past and I went looking for the answer and the solution. I found an application in Google Play that can even run the jar files that contain the desktop window. This means If you are a desktop developer, you can use this software. The name of this application: jre4android

My main language is Farsi, so please forgive me if there are any mistakes in my text

Upvotes: 0

oldcwj
oldcwj

Reputation: 1

you can install the app which called java runtime, you can search it on the googleplay

Upvotes: 0

ABC ABC
ABC ABC

Reputation: 29

use termux. it is a free android app, which emulate an linux terminal so u can install java there like in linux

apt install java

https://termux.dev/en/

Upvotes: 1

Saptarshi das
Saptarshi das

Reputation: 439

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:

Upvotes: 2

Alexander Hartmann
Alexander Hartmann

Reputation: 331

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 "$@"

Upvotes: 7

mportuesisf
mportuesisf

Reputation: 5617

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.

Upvotes: 6

dendini
dendini

Reputation: 3952

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/

Upvotes: 5

Florian Minges
Florian Minges

Reputation: 606

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.

Upvotes: 11

Related Questions