Command line can't find .java file from desktop

[Closed]
Report
Posts
10
Registration date
Tuesday December 11, 2012
Status
Member
Last seen
February 4, 2013
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,
I am not sure if this is the right place for this question, but I am having a problem running a Java program I wrote from the Windows 7 command prompt. I have saved the file as a .java extension on my desktop. Then, I open a command prompt and change to the desktop directory. Then I type in javac testnew.java and hit enter. Then I get an error that says,
"javac: Filenot found: Testnew.java
Usage: javac<options><source files>

but I know the file is there, I opened the command prompt right beside it on my desktop. Perhaps this is not the correct forum for this, but it says Programming forum, so I thought I would see if I could get some clarity on what is happening here....
Oh, and thanks in advance!!

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
Is your class name same as your file name ? Class name must match the file name.

You have not added any Package statement in your java file ? The java file must exists in the folder as defined by Package instruction in java file