Best way to run java on Android | Using Termux
Termux is an Android terminal emulator.
Answer of the question “ How to run java program in Android device ? “ is here.
To run java in android using Termux requires the installation of two termux packages.
- ecj : — (Eclipse compiler for java) this compile your java program and create .class file.
- dx : — it take .class file and redevelop .dex.

Before we Learn How to run java on android, lets take a look at Some Important Termux command we must remember:
- To clear all screen content run the command.
$ clear
- To find current working directory.
$ pwd
- To change our current working directory to another directory. Here I’m moving in /java directory/folder.
$ cd /java
- If you want one directory/folder to move
All in one free Computer Course Best Android app:
https://play.google.com/store/apps/details?id=com.computerdictionary.mcqtutorial.computerbitspradip
$ cd..
- If you want to back two directories use.
$ cd ../../
- To Create New File: To Create New Directory/Folder use mkdir commad Stands for make a new directory.
$ mkdir <new-directoy-name>
- To Delete Directory/Folder in Termux
$ rmdir <directory-name>
- To delete File
$ rm <file-name>
Here is How You Can Write and Run Java Programs on Your Android Devices
Step 1: Install Termux from Google Play
Step 2: Now Update and Upgrade Termux
- Open Termux
- To Update Termux type command
$ apt update
- To Upgrade Termux type command
$ apt upgrade
Step 3: To install ecj and dx run the following commands
$ apt install ecj
$ apt install dx
Step 4: To Create java file with .java extension.
- Type command
$ nano hello.java
- This will create hello.java file and open in nano text editor.
- Now write simple java program in nano text editor as given below
public class hello
{
public static void main(String args[])
{
System.out.println(“ Welcome to Java Learning Word With computer bits daily”);
}
}
- Note down that file_name and class name must be same to avoid error and confusion.
- Ctrl + s to save file and Ctrl + x to close nano text editor
Step 5: $ ecj hello.java
Step 6: $ dx — dex — output=hello.dex hello.class
Step 7: $ dalvikvm -cp hello.dex hello
For more reading : Best way to run java on Android | Using Termux (computerbitsdaily.blogspot.com)
Now you’re ready to Run Java program On Termux . Happy Coding | Keep Learning | |Keep Sharing | Stay Safe!