Most languages fall into camps: compiled (like C) or interpreted (like Python). Java does both. You write a .java file, compile it with javac, and get a .class file containing bytecode. Then you run that bytecode on the Java Virtual Machine.
Here is the full sequence:
You write HelloWorld.java in a text editor.
You run javac HelloWorld.java. The compiler checks your syntax and produces HelloWorld.class.
You run java HelloWorld. The JVM reads the bytecode and executes your program.
If you skip the compile step and try to run the .java file directly, you'll get an error. Java always requires both steps.