• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error: cannot find File

 
bra nbain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: "MyFirstApp.java" in a file on my desktop. But when I run it on command prompt, I get an error saying

"Error: cannot read: MyFirstApp.java"

I'm doing on command prompt: javac MyFirstApp.java, 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
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
javac Whatever.java
java Whatever
 
bra nbain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! Thanks! Thanks! I finnally got it to work! Thanks so much!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic