C:\Users>javac HelloWorld.java
error: file not found: HelloWorld.java
Usage: javac <options> <source files>
use --help for a list of possible options
Are you trying to run your first Java program via Windows Command Prompt or macOS Terminal 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 i.e. .java
- Also be sure the name the file specified matches with the case in the command (case-sesitivity).
- Make sure the location where you are running this file has permissions.
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.
- Setting up Java Home: https://code2care.org/pages/setting-java_home-environment-variable-on-windows-operating-system
Comments:
- I am learning Java and got this particular error while doing my practice, helped, thanks!
anon 08 Nov 2020 18:11:04 GMT
- Further comments disabled!
More Posts related to Java,
- Get the current timestamp in Java
- Java Stream with Multiple Filters Example
- Java SE JDBC with Prepared Statement Parameterized Select Example
- Fix: UnsupportedClassVersionError: Unsupported major.minor version 63.0
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- 7 deadly java.lang.OutOfMemoryError in Java Programming
- How to Calculate the SHA Hash Value of a File in Java
- Java JDBC Connection with Database using SSL (https) URL
- How to Add/Subtract Days to the Current Date in Java
- Create Nested Directories using Java Code
- Spring Boot: JDBCTemplate BatchUpdate Update Query Example
- What is CA FE BA BE 00 00 00 3D in Java Class Bytecode
- Save Java Object as JSON file using Jackson Library
- Adding Custom ASCII Text Banner in Spring Boot Application
- [Fix] Java: Type argument cannot be of primitive type generics
- List of New Features in Java 11 (JEPs)
- Java: How to Add two Maps with example
- Java JDBC Transition Management using PreparedStatement Examples
- Understanding and Handling NullPointerException in Java: Tips and Tricks for Effective Debugging
- Steps of working with Stored Procedures using JDBCTemplate Spring Boot
- Java 8 java.util.Function and BiFunction Examples
- The Motivation Behind Generics in Java Programming
- Get Current Local Date and Time using Java 8 DateTime API
- Java: Convert Char to ASCII
- Deep Dive: Why avoid java.util.Date and Calendar Classes
More Posts:
- Division between two numbers - C-Program
- How to install Microsoft Teams on Mac using Terminal (Silently) - Teams
- How to lock Notepad++ tabs? - NotepadPlusPlus
- Add or remove users from sudo group - Ubuntu - Ubuntu
- Shortcut: How to delete a complete line in Nano Editor - Linux
- Java JDBC Connection with Database using SSL (https) URL - Java
- Json Serialization and Deserialization using Java Jackson - Java
- [Java Threads] Should we extend Thread Class or implement Runnable interface - Java