1. Compile Use the javac command to compile the Java file into bytecode:

      javac HelloWorld.java
      

    This produces a HelloWorld.class file, which contains platform-independent bytecode.

  2. Run Execute the program using the java command:

      java HelloWorld
      

    The JVM loads the .class file, translates it to machine code, and runs the program.