Java programs can be compiled and run from the Linux command line using the JDK tools javac and java.
Check Java is installed
java -version
javac -version
If javac is missing, install a JDK package rather than only a runtime package.
Compile a Java file
javac Hello.java
This creates a compiled Hello.class file.
Run the program
java Hello
Use the class name without the .class extension when running it.