Java is a well-known programming language used to create apps, software, and games. It is simple to understand and follows a clear structure, which makes it a good choice for beginners. Learning Java also helps you build strong programming basics.
Installation Commands
Update Termux and install Java:
pkg update && pkg upgrade
Install OpenJDK (recommended version):
pkg install openjdk-17 -y
You can also install other versions:
pkg install openjdk-21
Check Java version:
java -version
Check compiler version:
javac -version
Usage Commands
Create a Java file:
nano Hello.java
Write simple Java code:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello Java in Termux");
}
}Save and exit:
- CTRL + X → Y → Enter
Compile the Java program:
javac Hello.java
Run the program:
java Hello
Compile and run in one line:
javac Hello.java && java Hello
Run Java file directly:
java Hello.java
Create JAR file:
jar cvf hello.jar Hello.class
Run JAR file:
java -jar hello.jar








