File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Error: cannot find File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error: cannot find File" Watch "Error: cannot find File" New topic

Error: cannot find File

bra nbain

Joined: Dec 26, 2008
Posts: 10
It's me, again. I have to be the person with the most problems in getting Java to work. I have set my path variable. It's corrcect because now javac works. But when I save a file -in this case I save a file: "" in a file on my desktop. But when I run it on command prompt, I get an error saying

"Error: cannot read:"

I'm doing on command prompt: javac, whats wrong?

--Thanks so much for all of those people who helped me before and might
help here
[ January 02, 2009: Message edited by: bra nbain ]
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

The Windows command prompt has a notion of a "current directory." If you type "dir" to see a listing of files, it'll be the files in the current directory that get listed. Depending on the version of Windows you're using the default current directory might be any number of things, but it'll pretty much never be your desktop folder.

You can change your current directory (not the default, which will be the same every time you start the command prompt; you change it just for the current session) using the "cd" command, as in

cd c:\Documents and Settings\nbain\Desktop

(where I used "nbain" for your Windows user name, since I don't know your real one.) If you issue that "cd" command correctly, you should find that your "javac" command will then work.

But the Desktop folder is a lousy place to put things. Generally you want to create a directory to keep your Java work in:

mkdir c:\java

and then store your work in that "c:\java" folder. When you want to compile and run your programs,

cd c:\java
java Whatever

[Jess in Action][AskingGoodQuestions]
bra nbain

Joined: Dec 26, 2008
Posts: 10
Thanks! Thanks! Thanks! I finnally got it to work! Thanks so much!
I agree. Here's the link:
subject: Error: cannot find File
It's not a secret anymore!