• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Error: cannot find File

 
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 ]
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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!
 
Trust God, but always tether your camel... to this tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!