javac: file not found: first.java Usage: javac <options> <source files>

Viewed 189313

I have a filename named "first.java" saved on my desktop in notepad++. When I run the cmd command "javac first.java" it gives me this error.

javac: file not found: first.java 
Usage: javac <options> <source files>

I know you are required to go to C:\Programfiles\java\jdk.

and in my C:\Program Files\Java\ I have thesE folders

"jdk1.8.0" "jre6" "jre8"

In C:\Program Files (x86)\Java I have this folder
"jre6"

The Environmental settings are as follows

CLASSPATH
C:\Program Files\Java\jre8\bin
Variable name: LEJOS_NXT_JAVA_HOME
Variable value: C:\Program Files (x86)\Java\jdk1.6.0_21\bin

PATH
Variable name: PATH
Variable value: C:\Program Files\Java\jdk1.8.0\bin

Please tell me where I am going wrong. I have read several posts on the Internet, and I can't figure it out.

14 Answers

I had same problem. The origin of the problem was the creation of text file in Notepad and renaming it as a java file. This implied that the file was saved as WorCount.java.txt file.

To solve this I had to save the file as java file in an IDE or in Nodepad++.

Sometimes this issue occurs, If you are creating a java file for the first time in your system. The Extension of your Java file gets saved as the text file.

e.g Example.java.txt (wrong extension)

You need to change the text file extension to java file.

It should be like:

Example.java (right extension)

First set your path to C:/Program Files/Java/jdk1.8.0/bin in the environment variables. Say, your file is saved in the C: drive Now open the command prompt and move to the directory using c: javac Filename.java java Filename

Make sure you save the file name as .java.

If it is saved as a text file name then file not found error results as it cannot the text file.

just open file then click on save as then name it as first.java then in that box there is another dropdown in that dropdown (save as type) select type as all and save it now you can compile it

first set the path of jdk bin steps to be follow: - open computer properties. - Advanced system settings - Environment Variables look for the system variables -Click on the "path" variable - Edit copy the jdk bin path and done.

The Problem is you just open the command prompt which is default set on current user like "C:\users\ABC>" You have to change the location where your .java file store like "D:\javafiles>"

Now you are able to run the command javac filename.java

Related