What is the Command to Compile a Java Program?

To Compile a Java program in CMD, you can use the javac command followed by the file name. For example,

javac PrintHelloWorld.java

I tried running a java file containing the following code. But I got an error saying that the file doesn’t exist.

class DemoFile  
{  
public static void main(String args[])  
{  
System.out.println("Hello!");  
System.out.println("Java");  
}  
}

Are you sure that you run the command after navigating to the directory using cd command?