I want to be able to compile and run basic java apps within the android terminal termux. I checked out Terminal IDE, but that is incompatible with Android 5.0+. Additionally, I tried to install the arm64 jdk from Oracle's website, which android fails to recognize. I am running CM 13 and to clarify, I want to be able to run commands like javac and java directly from my phone.
-
*I want to be able to run commands like javac and java directly from my phone* Short answer; **no**. Longer answer; maybe if you want to run a full system emulator but it will be ***slow***. – Elliott Frisch Apr 11 '16 at 03:23
-
Which emulator would be sufficient and how would I implement it. My phone has a decent processor so I would like to try the emulator out – moderatelygood Apr 11 '16 at 03:26
-
See this [Reddit](https://www.reddit.com/r/androidapps/comments/3hjf11/is_there_any_good_pc_virtualizationx86_emulator/). – Elliott Frisch Apr 11 '16 at 03:33
-
It's promising that in the future Google will contribute to the `OpneJDK` project. So we should see new Java features on Android, but that's only about Java language features. Google can still keep some own proprietary binary format, like `dex` is right now. It's a question how much you'll be able to find `javac` and other tools. But the embracement of the `OpenJDK` is a promising direction. – Csaba Toth Apr 12 '16 at 05:34
-
It would be great if the integration of OpenJDK into Android N would ensure capability to run it directly in the terminal, but historically Google has made many java updates for android that only serve the purpose of android app development rather than java development. I guess until then we can never be certain of the status of direct access to the jdk commands within android. – moderatelygood Apr 13 '16 at 06:40
-
@moderatelygood , did you get JDK working on Device? – Harshiv Mar 24 '17 at 12:43
4 Answers
If you have Termux, you can download the deb file here, and install it with apt-get install /path/to/deb
. A command to download and install the JRE and JDK for arm:
cd ~ # Change to home directory
apt-get install -y wget # BusyBox wget doesn't support HTTPS
hash -d wget # Forgets the BusyBox wget path so new one is used
wget https://archive.org/download/openjdk-9-jre-headless_9.2017.8.20-1_x86_64/openjdk-9-jre-headless_9.2017.8.20-1_arm.deb # Download JRE
wget https://archive.org/download/openjdk-9-jre-headless_9.2017.8.20-1_x86_64/openjdk-9-jdk-headless_9.2017.8.20-1_arm.deb # Download JDK
apt-get install -y ./openjdk-9-jre-headless_9.2017.8.20-1_arm.deb ./openjdk-9-jdk-headless_9.2017.8.20-1_arm.deb # Install the files
rm openjdk-9-*.deb # Remove the files after because they're huge
Or a one-liner to copy and paste:
cd ~ && apt-get install -y wget && hash -d wget && wget https://archive.org/download/openjdk-9-jre-headless_9.2017.8.20-1_x86_64/openjdk-9-jre-headless_9.2017.8.20-1_arm.deb && wget https://archive.org/download/openjdk-9-jre-headless_9.2017.8.20-1_x86_64/openjdk-9-jdk-headless_9.2017.8.20-1_arm.deb && apt-get install -y ./openjdk-9-jre-headless_9.2017.8.20-1_arm.deb ./openjdk-9-jdk-headless_9.2017.8.20-1_arm.deb && rm openjdk-9-*.deb
To install for another architecture, replace occurences of "arm" with the correct architecture. There are files for "arm" (most 32-bit phones), "aarch64" (ARM64/armv8, most 64-bit phones), "i686" (x86), and "x86_64". Most phones have either arm or aarch64. I believe the arm version should at least work on aarch64 (may be wrong?), so arm should work for almost everyone. But if you know what your device has, use that instead.
Edit: to find your device's architecture, run uname -m
from Termux.

- 131
- 1
- 10
@moderatelygood Go to Google Play Store and download GNURoot Debian. It is a fakeroot, i.e. terminal emulator. Many other terminal emulators are available in the Play Sore, but this ine is very good. It lives at https://github.com/corbinlc/GNURootDebian and website is http://corbinlc.github.io/GNURootDebian You can download many packages like this:
apt-get update
apt-get install default-jdk
apt-get install python
and so on.
You would be able to compile/run programs in these languages. Use some text editor to write programs, like Jota Text Editor, also available in Play Store.

- 331
- 3
- 8
Actually Terminal can be used if you're only interested in javac
, java
, jar
. That is , you can use these three on Lollipop. I am using Terminal IDE on Android 5.1.1, it works as expected. The usable version can be found at https://www.dropbox.com/s/h2d23ecbrt2akeu/terminalide-2.02-binary-mod-signed.apk?dl=0. If you want to give it a try then open this mod terminal and do : cp /system/lib/libjavacrypto.so ~/system/lib
, copying this library should do the job(did for me) leaving java
and dx
commands working.

- 376
- 2
- 17
-
Unfortunately, the link you posted gives a 404 error. I think it is outdated but if you can verify and/or update the link that would be great. – moderatelygood Apr 11 '16 at 03:50
-
The apk file downloads but Install System throws a java io exception when overwrite is both checked and unchecked – moderatelygood Apr 11 '16 at 04:24
-
If you had Terminal IDE already installed before this MOD installation, it won't work, in that case un-install previous version,then install The MOD – Harshiv Apr 11 '16 at 04:27
-
-
-
-
2 rename .mp3 with system.xx.tar.gz, extract it and move it's content to terminal IDE's ~/system/folder – Harshiv Apr 11 '16 at 04:32
-
Since Terminal IDE is not installing, I cannot see its system folder location – moderatelygood Apr 11 '16 at 05:31
-
I found the system folder location but the installer now throws null pointer exception for searching through an array with length 0 – moderatelygood Apr 11 '16 at 05:53
-
if rooted,Go to : `/data/data/com.spartacusrex.spartacussuide/files/` if you don't see following folders there, then create them manually : – Harshiv Apr 11 '16 at 07:14
-
`system` `tmp` ,then put extracted contents of system.tar.gz there. Or other simple way: if you can install the Terminal IDE from play store and installation of system is done, then you just have to replace the ~/system/bin/ folder's content with that extracted MOD's system /bin/. Only replacing binaries in there should work too. Not sure if Google messed with /system/lib again in Marshmallow. – Harshiv Apr 11 '16 at 07:20
-
-
And you can browse to `/data/data/com.spartacusrex.spartacuside/files/` and have read/write rights ? – Harshiv Apr 11 '16 at 15:50
-
No i used root permissions to put the system folder there so ill try giving the app root permissions – moderatelygood Apr 11 '16 at 15:52
-
Try it. If doesn't work, then try downloading the Play Store version of Terminal IDE(If it lets you install the system then things will be fine. In any case inform here what happens. – Harshiv Apr 11 '16 at 16:01
-
I downloaded the app from the Play Store then moved the system folder into /data/data/com.spartacusrex.spartacuside/files and created a tmp folder as well. This time there is a filenotfound exception due to permission denied. The app does not request root permission but it needs root permissions to install system for some reason. But I suspect the app will work once I force it to run as root. – moderatelygood Apr 11 '16 at 18:35
-
I am getting this error, haven't typed it all up to test it though http://m.imgur.com/i1SpCu7 – moderatelygood Apr 12 '16 at 02:58
-
1Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/108873/discussion-between-harshiv-and-moderatelygood). – Harshiv Apr 12 '16 at 03:03
Java can installed on termux. INSTALLION of java on termux take very short period of time and install directly from termux-source, this program really work for me, i am dame sure it will also work for you also......
git clone https://github.com/EagleComrade/Termux-java.git
cd Termux-java
chmod +x install.sh
bash install.sh

- 1
- 1