I have JDK1.3 installed on my system. Obviously, the JVM is in c:\jdk1.3\bin folder. Any .java file created in the bin folder runs fine. But if i save my .java source code in some other folder say c:\jdk1.3\bin\prog\abc.java and try to compile it, I get an error "File cannot be found". Please help me.
First, do not put your own .java or .class files in the JDK's bin directory. This is for Java's "inner workings," and mixing your own files in there is bound to complicate things.
If there is no CLASSPATH specified, Java's default (since version 1.2) is to look in the current directory. So it sounds like you have a system CLASSPATH set (so you're not getting the default behavior) and the set CLASSPATH does not include a dot (.) to indicate the current directory.
The best approach is to avoid a system CLASSPATH entirely. But if you must set one, be sure it includes a dot.
Originally posted by Rekha Anand: ...I would like to mention that I have set the path and the classpath to path=%path%;c:\jdk1.3\bin\rekha progs
and classpath=%classpath%;c:\jdk1.3\bin\rekha progs...
The PATH should point to...
...because that's where the executable tools are (like javac and java). It should not point to the "rekha progs" directory. See Update the PATH variable in the installation instructions.
A system CLASSPATH should not be needed at all, because Java's default is to look in the current directory. If you do need a system CLASSPATH (and again, you probably do not need this), then make sure it includes a dot (.) so that class files can be found in the current directory. See Check the CLASSPATH variable in the installation instructions.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
posted 10 years ago
Finally... I got it. I want to thank all forum members who helped me on this.