I hope you mean you set PATH "to include" that location, rather than
"to" that location... It's also worth mentioning that any command
prompt opened before you did that will not reflect the change, so you
should open a new one.
Sun has long recommended against setting a CLASSPATH variable, and many
here will concur (myself included). When you need to set a classpath,
you should do so on the command line of any individual javac or java
command -- or in the manifest file if using a jar file that's supposed
to be "executable" on its own.
The command you describe -- if everything else is correct, and you don't
provide enough info to determine that with certainty -- should be able
to compile your MyWindow.java file provided it makes use of nothing
except built-in classes and has no "package" statement, since they're
all right there in various proper spots beneath the jdk1.5.0_10
directory you mention.
= Steve =
O.K. Let me make myself clear a little bit:
I have installed Java SDK 5.0 in its default location in Windows XP. I
have set PATH permanently to:
C:\Program Files\Java\jdk1.5.0_10\bin
because javac.exe and java.exe are at that location.(by using Systems ->
Advanced Tab->Environment Variables)
But now, if I "javac MyWindowGui.java", many classes cannot be found,
like Graphics.java, Point.java, etc. I found I need to do:
(1) unzip Java source file, find Graphics.java and copy to the same
directory as MyWindowGui.java
(2) remove the line "package ..." in the Graphics.java
(3) find Point.java and do the same thing
Because MyWindowGui.java uses many other Java classes, it is almost
impossible to find all the class files and copy to the same directory as
MyWindowGui.java and remove the line "package ..." in the file.
I think I need to set the CLASSPATH so all of them can be found in their
original location. But I don't know what the value should I set to
CLASSPATH. Currently, by using System->Advanced Tab->Environment
Variables, I set CLASSPATH to:
.;C:\Program Files\Java\jre1.5.0_10\bin;C:\Program
Files\Java\jre1.5.0_10\lib
"javac MyWindowGui.java" still cannot find all the classes they need.[/QUOTE]
As I said, if you've properly done the installation and set PATH, you do
*not* need a CLASSPATH variable, nor do you need to obtain any of the
source files for classes that are part of Java 5. You haven't shown any
code, and that's probably the source of your error. You have an import
statement for "java.awt.*", or separate ones for "java.awt.Graphics" and
"java.awt.Graphics", don't you?