how can I install java runtime on Android device?

Solution 1:

Try Termux, a linux terminal emulator for android.A minimal base system is installed automatically - additional packages are available using the APT package manager. You can use following commands to install java8.

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

When installed, run java -version to check, if it's correcty installed. After that you can run java using Java command.

Solution 2:

First of all install 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

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 :

$ cd /sdcard/<folder name>

Replace foldername with your download folder.

$ mv file1 file2 $HOME

Replace file1 and file2 with actual filenames.

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.

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. If you don’t see an Error you're good to go.

See Source

Solution 3:

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