error: file not found: HelloWorld.java


Javac file not found error
Javac file not found error
C:\Users>javac HelloWorld.java
error: file not found: HelloWorld.java
Usage: javac  
use --help for a list of possible options

Are you trying to run your first Java program via Command Prompt and unable to run because of the above error, there are few things that can go wrong,

  • Do you have file available at the location where you are running the javac command. If the file is not found you can get this error. Do dir and check if the file is available in this location.
  • Make sure that the file extension is provided correctly .java
  • Make sure that the file name is in proper case.
  • Make sure the location where you are running this file has permissions.
Code Sample:
public class HelloWorld {

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

}

If you are able to find the javac command that indicates that your JAVA_HOME is set properly, it's just the file is not accessible.