how to run java file in command prompt code example Example 1: run java file javac hello.java Example 2: how to run a java file in terminal javac FirstJavaProgram.java