I'm having real problems getting started with Java . . .
I've downloaded the JDK 1.4 from Sun, but I can't seem to get my program compiled.
I'm running Windows ME and I've set the path, following the installation notes, but when I go to MSDOS and type the name of my program (a simple 5 line program copied from an introductory book on Java, written on Notepad) - it doesn't work.
I type javac Hello.java, and I get the message
error: cannot read Hello.java
So the compiler can't find the text file of the program I've written in notepad - but how do I get it to find then compile the file (which is stored in C\jdk1.4\bin)?
Do I need to type another line of code so that the compiler can find my program - and if so what code or path instructions do I need?
I'm sure this is a trivial problem, but It's very frustrating because it's stopping me from getting started with Java.
Any suggestions would be very warmly welcomed.
David E.Quinn
>I type javac Hello.java, and I get the message
>
>error: cannot read Hello.java
>
>So the compiler can't find the text file of the program
>I've written in notepad - but how do I get it to find
>then compile the file (which is stored in C\jdk1.4\bin)?
Here are a few things which should help you get started.
1) The name, spelling, and capitalization of the file name, must match exactly as you have named your class. For example, if you have declared your class as follows:
class David {
}
Then the name of the file must be "David.java".
DAVID.java and david.java will not work.
2) You can add C:\jdk1.4\bin to your PATH statement, so that DOS can find javac without your explicitly specifying the path. Then, from the directory where your java file is, you can issue a command like the following:
javac Hello.java
Or, you can give the full path of where javac is located:
C:\jdk1.4\bin\javac Hello.java
3) While in the C:\jdk1.4\bin directory, you can explicitly specify the location of your Hello.java file:
javac C:\MyJavaFiles\Hello.java
4) You can always (from whatever directory you're in) explicitly specify the location of both javac and your Hello.java file:
C:\jdk1.4\bin\javac c:\MyJavaFiles\Hello.java
-Dennis Borg