java 是否可以在 android 设备上安装 JDK?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36539308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to install the JDK on an android device?
提问by moderatelygood
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.
我希望能够在 android 终端 termux 中编译和运行基本的 java 应用程序。我检查了终端 IDE,但它与 Android 5.0+ 不兼容。此外,我尝试从 Oracle 的网站安装 arm64 jdk,但 android 无法识别。我正在运行 CM 13 并澄清一下,我希望能够直接从我的手机运行 javac 和 java 等命令。
回答by rps
@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/GNURootDebianand website is http://corbinlc.github.io/GNURootDebianYou can download many packages like this:
@moderatelygood 前往 Google Play 商店并下载 GNURoot Debian。它是一个fakeroot,即终端模拟器。Play Sore 中提供了许多其他终端仿真器,但这个ine 非常好。它位于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 商店中使用。
回答by beewall
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:
如果你有Termux,你可以在这里下载 deb 文件,然后用apt-get install /path/to/deb
. 为 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. 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.
要为其他架构安装,请用正确的架构替换出现的“arm”。有“arm”(大多数 32 位手机)、“aarch64”(ARM64/armv8、大多数 64 位手机)、“i686”(x86)和“x86_64”的文件。大多数手机都有 arm 或 aarch64。我相信 arm 版本至少应该适用于 aarch64(可能是错误的?),所以 arm 应该适用于几乎所有人。但是,如果您知道您的设备有什么,请改用它。
Edit: to find your device's architecture, run uname -m
from Termux.
编辑:要找到您设备的架构,请uname -m
从 Termux运行。
回答by Harshiv
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.
实际上,如果您只对javac
, java
,感兴趣,可以使用终端jar
。也就是说,你可以在 Lollipop 上使用这三个。我在 Android 5.1.1 上使用终端 IDE,它按预期工作。可用版本可以在https://www.dropbox.com/s/h2d23ecbrt2akeu/terminalide-2.02-binary-mod-signed.apk?dl=0找到。如果您想尝试一下,请打开此 mod 终端并执行 : cp /system/lib/libjavacrypto.so ~/system/lib
,复制此库应该可以完成工作(为我做的)离开java
并运行dx
命令。