简体   繁体   English

如何在 Android 设备上安装 java 运行时?

[英]how can I install java runtime on Android device?

I need to install some packages and Linux programs on my android devices .我需要在我的 android 设备上安装一些软件包和 Linux 程序 for example I want to use something similar YUM or get-apt command ( I know these are Linux Commands ) through windows powershell connected to my android device.例如,我想使用类似的 YUM 或 get-apt命令(我知道这些是 Linux 命令),通过 windows powershell 连接到我的 android 设备。 but it does not recognize these commands.但它不识别这些命令。 even ADB does not work , eg adb update -y is unknown command.甚至 ADB 也不起作用,例如adb update -y is unknown command。 How can i do this, is it possible.我该怎么做,这可能吗? if the android kernel is linux so I guess there must be a way.如果 android kernel 是 linux 那么我想一定有办法。 I checked this but didnt help me:我检查了这个但没有帮助我:

Is it possible to install the JDK on an android device? 是否可以在 android 设备上安装 JDK?

Thanks谢谢

EDITED: I used the link below, thanks to my friend for good answer.编辑:我使用了下面的链接,感谢我朋友的好回答。 this is the command i used:这是我使用的命令:

pkg install wget && wget https://raw.githubusercontent.com/MasterDevX/java/master/installjava && bash installjava pkg 安装 wget && wget https://raw.githubusercontent.com/MasterDevX/java/master/installjava && bash installjava

BUT when i run java command it says "Killed".但是,当我运行 java 命令时,它显示“Killed”。 No Idea!不知道!

Try Termux , a linux terminal emulator for android.A minimal base system is installed automatically - additional packages are available using the APT package manager.试试Termux ,一个 android 的 linux 终端仿真器。自动安装最小的基本系统 - 使用 APT package 管理器可以使用其他软件包。 You can use following commands to install java8.您可以使用以下命令安装 java8。

  1. pkg install git包安装 git
  2. git clone https://github.com/MasterDevX/Termux-Java.git git 克隆https://github.com/MasterDevX/Termux-Java.git
  3. cd Termux-Java cd Termux-Java
  4. chmod +x installjava chmod +x 安装java
  5. bash installjava bash installjava

When installed, run java -version to check, if it's correcty installed.安装后,运行java -version检查是否安装正确。 After that you can run java using Java command.之后,您可以使用Java命令运行 java。

First of all install termux.首先安装termux。 Then run following commands:然后运行以下命令:

$ pkg update -y && pkg upgrade -y

$ termux-setup-storage

And give the storage permission.并授予存储权限。 After that download these 2 files.之后下载这两个文件。

JDK-9: 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 JDK-9: 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

JRE-9: 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 JRE-9: 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

Remember the filenames, and the folder where you downloaded the files.记住文件名和下载文件的文件夹。

Go back to termux and run: Go 回到 termux 并运行:

$ cd /sdcard/<folder name>

Replace foldername with your download folder.将文件夹名称替换为您的下载文件夹。

$ mv file1 file2 $HOME

Replace file1 and file2 with actual filenames.将 file1 和 file2 替换为实际的文件名。

Alternative:选择:

If you don't want to download and move files manually you can use this commands (not recommended):如果您不想手动下载和移动文件,可以使用以下命令(不推荐):

$ pkg install wget -y

$ 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

$ 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

It will download files within your termux home directory.它将下载您的 termux 主目录中的文件。

Finally run,终于跑了,

$ apt-get install -y./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

And You're done.你完成了。 Try typing java or javac .尝试输入javajavac If you don't see an Error you're good to go.如果您没有看到错误,您可以使用 go。

See Source 见源

$ apt update && apt upgrade $ apt install openjdk-17 $ apt update && apt 升级 $ apt install openjdk-17

First, you need to install termux from their f droid link.首先,您需要从他们的 f droid 链接安装 termux。 Their playstore version is not updated.他们的 Playstore 版本没有更新。 You can find the fdroid link from their github repository.您可以从他们的 github 存储库中找到 fdroid 链接。

run the following command:运行以下命令:

apt update
apt search openjdk

If you find a version of openjdk available, for example: presently openjdk-17 is available如果你发现有可用的 openjdk 版本,例如: presently openjdk-17 is available

install it using command:使用命令安装它:

apt install package-name

example:例子:

apt install openjdk-17

follow the prompts and java will be installed in your termux.按照提示操作,java 将安装在您的 termux 中。

Download java is possible Check this github link可以下载 java 检查这个 github 链接

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

It provides direct installtion of java from termux-source Installtion from unwanted sources are not really trusted So this tool is realy great Do the following for install java without errors.它提供从 termux-source 直接安装 java 从不需要的来源安装并不是真正可信的 所以这个工具真的很棒 执行以下操作以无错误地安装 java。

      pkg install git

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

    cd Termux-java
 
    chmod +x install.sh

    ./install.sh

Java is installed....... Java 已安装......

Install termux and run these commands安装 termux 并运行这些命令

pkg update

pkg install openjdk-17

java --version

Install ubuntu on termux from anlinux... Then use从anlinux在termux上安装ubuntu ...然后使用

$ apt install default-jdk

Job done!任务完成!

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

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