简体   繁体   中英

Is it possible to install the JDK on an android device?

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.

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.

@moderatelygood Go to Google Play Store and download GNURoot Debian. It is a fakeroot, ie 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.

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.

该死的 Termux 的好解决方案: https : //github.com/MasterDevX/Termux-Java一个安装命令,你可以用 Java 做任何你想做的事

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM