-1

i am facing problem while compiling a java program i am using command promt to run the program . i have kept the file name and class name both same . also i set the path , i have also set the classpath .

the only reason i can come up with is that the may be the file gets saved with a ".txt" extension inside of a ".java" extensions, as filename.java.txt.

it shows the error

javac : file not found <file name.java>

if anyone have any idea about this please tell me.

Connorelsea
  • 2,308
  • 6
  • 26
  • 47
Himanshu
  • 9
  • 3
  • 3
    Make sure "Hide known extensions" is turned off in your OS preferences, and rename your file to fix the extension. – khelwood Feb 14 '15 at 19:48
  • If one of the responses below solves your problem, make sure to select the check mark near it to mark it as the accepted answer. If neither work, let us know. – Connorelsea Feb 14 '15 at 19:49

2 Answers2

0

If you are using Notepad, or a similar program to save your files, surround the entire file name in quotes in the save bar.

For example, instead of writing

program.java

Select "All Files" instead of "Text files", and then in the save text box, write

"program.java"

How your save file should look:

How your save should look

If this is the case, I would recommend using a text editor that is specifically for coding such as Notepad++ or Sublime Text

Connorelsea
  • 2,308
  • 6
  • 26
  • 47
  • that problem resolved now new problem could not find the main class – Himanshu Feb 14 '15 at 20:08
  • this one also done ,now another one compiled successfully. but while interpreting gives error java is not recognized as internal or external command – Himanshu Feb 14 '15 at 20:15
  • If this fixed it, then mark this as accepted. Here is a post on how to fix your most recent problem: http://stackoverflow.com/questions/15796855/java-is-not-recognized-as-an-internal-or-external-command – Connorelsea Feb 14 '15 at 20:41
0

If you are on Windows Operating System then give the file Name in double quotes like this

"MyJavaFile.java"

then press Save button , it will save your file with java extension

Neeraj Jain
  • 7,643
  • 6
  • 34
  • 62