Hello, i've worked with COBOL and more recently with VB.net but I need to learn Java for school and im at a loss just getting started. Ive downloaded JDK from Sun and I "think" ive done the "path" variable correctly. Im trying this in a DOS window, typing javac at the command line. Correct? Im using XP Prof. If i type javac at the command prompt it will bring up the list of options. Am I correct in assuming that means its installed correctly? I will do a sample program called MyFirstApp.java and when i type javac MyFirstApp.java at the command line, I get "error: cannot read : MyFirstApp.java". Any ideas on what I can look for?
MyFirstApp.java needs to be in your current directory for this to work. An extremely common mistake is to create your first program in Notepad, save it as MyFirstApp.java, and have Notepad helpfully save it as MyFirstApp.java.txt! Ain't that nice?
If that's the problem try putting double quotes around the name when you save the file -- i.e., "MyFirstApp.java". Or use something better to edit code -- there are many programmer's editors out there.
That error sounds like javac is installed correctly, but it can't see the file. Check your spelling and also capitalization. Remember Java is case-sensitive.
posted 13 years ago
Ive saved MyFirstApp with quotes so its "MyFirstApp.java" when i did it in notepad. The book I have told me to do that. I start a class the end of august in Java but i dont want to wait to learn then, im trying to get a head start. What i did was save it directly to the C drive so "hopefully" that would make it easier for the javac to find it. That way im not typing the location and leaving myself open for mistakes. Is there someplace else I should save it to make it easier to find?
You want to save it wherever your command prompt is. Do you know how to use a few basic command-prompt commands like "dir", "cd", "pwd", etc, to get around? If not, here is a page that describes all this stuff.
Once you understand these commands, then make a directory, something like C:\JavaWork, then save your documents there, and use "cd" to go to that directory before you run javac.
Just one quick afterthought, ive searched around and went over the "how to ask a question" and I hope I havent done anything wrong. Just to be clear, the only reason im asking for help is im stuck at the beginning. I just want to be able to compile and run a simple "Hello World" type application. Its the getting up and going thats a problem now. Once i know the "how", im perfectly willing to sit and problem solve a program all by myself. I would consider myself a failure if i keep coming back, on the contrary, i want to learn all on my own and stand on my own two feet. I can read, I respect your time and your efforts and would not want to take advantage of them. Thank you ahead of time.