简体   繁体   English

是否可以在 Android 设备上安装 JDK?

[英]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.我希望能够在 android 终端 termux 中编译和运行基本的 java 应用程序。 I checked out Terminal IDE, but that is incompatible with Android 5.0+.我检查了 Terminal IDE,但它与 Android 5.0+ 不兼容。 Additionally, I tried to install the arm64 jdk from Oracle's website, which android fails to recognize.此外,我尝试从 Oracle 的网站安装 arm64 jdk,android 无法识别它。 I am running CM 13 and to clarify, I want to be able to run commands like javac and java directly from my phone.我正在运行 CM 13,澄清一下,我希望能够直接从我的手机运行 javac 和 java 等命令。

If you have Termux , you can download the deb file here , and install it with apt-get install /path/to/deb .如果你有Termux ,你可以在这里下载 deb 文件,并使用apt-get install /path/to/deb安装它。 A command to download and install the JRE and JDK for arm:为 arm 下载和安装 JRE 和 JDK 的命令:

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.要为其他架构安装,请用正确的架构替换出现的“arm”。 There are files for "arm" (most 32-bit phones), "aarch64" (ARM64/armv8, most 64-bit phones), "i686" (x86), and "x86_64".有“arm”(大多数 32 位手机)、“aarch64”(ARM64/armv8、大多数 64 位手机)、“i686”(x86)和“x86_64”的文件。 Most phones have either arm or aarch64.大多数手机都有 arm 或 aarch64。 I believe the arm version should at least work on aarch64 (may be wrong?), so arm should work for almost everyone.我相信 arm 版本至少应该适用于 aarch64(可能是错误的?),所以 arm 应该适用于几乎所有人。 But if you know what your device has, use that instead.但是,如果您知道您的设备有什么,请改用它。

Edit: to find your device's architecture, run uname -m from Termux.编辑:要查找设备的架构,请从 Termux 运行uname -m

@moderatelygood Go to Google Play Store and download GNURoot Debian. @moderatelygood 前往 Google Play 商店并下载 GNURoot Debian。 It is a fakeroot, ie terminal emulator.它是一个fakeroot,即终端模拟器。 Many other terminal emulators are available in the Play Sore, but this ine is very good. Play Sore 中提供了许多其他终端仿真器,但这个ine 非常好。 It lives at https://github.com/corbinlc/GNURootDebian and website is http://corbinlc.github.io/GNURootDebian You can download many packages like this:它位于https://github.com/corbinlc/GNURootDebian和网站是http://corbinlc.github.io/GNURootDebian您可以下载许多这样的软件包:

apt-get update apt-get 更新

apt-get install default-jdk apt-get install default-jdk

apt-get install python apt-get 安装 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.使用一些文本编辑器编写程序,例如 Jota 文本编辑器,也可在 Play 商店中使用。

Actually Terminal can be used if you're only interested in javac , java , jar .实际上,如果您只对javacjavajar感兴趣,可以使用 Terminal 。 That is , you can use these three on Lollipop.也就是说,你可以在 Lollipop 上使用这三个。 I am using Terminal IDE on Android 5.1.1, it works as expected.我在 Android 5.1.1 上使用终端 IDE,它按预期工作。 The usable version can be found at https://www.dropbox.com/s/h2d23ecbrt2akeu/terminalide-2.02-binary-mod-signed.apk?dl=0 .可用版本可以在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.如果您想尝试一下,请打开此 mod 终端并执行以下操作: cp /system/lib/libjavacrypto.so ~/system/lib ,复制此库应该可以完成工作(为我做的)让javadx命令工作。

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

Java can installed on termux. Java 可以安装在 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......在 termux 上安装 java 需要很短的时间并直接从 termux-source 安装,这个程序真的对我有用,我敢肯定它也对你有用......

 git clone https://github.com/EagleComrade/Termux-java.git

 cd Termux-java
 
 chmod +x install.sh

 bash install.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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