Env Run
# Java Example - How to Run a Compiled Java File
[ Java Example](#)
In this example, we demonstrate how to run a compiled HelloWorld.java file. The Java code is as follows:
## HelloWorld.java File
public class HelloWorld{public static void main(String[]args){System.out.println("Hello World"); }}
Next, we use the `javac` command to compile the Java file. After executing this command, a HelloWorld.class file will be generated in the current directory. We can then use the `java` command to run the compiled file:
c:jdkdemoapp> javac HelloWorld.java c:jdkdemoapp> java HelloWorld
The output of the above code example is:
Hello World
[ Java Example](#)
YouTip