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.
Dhaval Shah
Ranch Hand
Joined: Jun 10, 2005
Posts: 56
posted
0
Please execute this command on the command prompt - > set classpath=%classpath%;c:\jdk1.3\bin\prog
As a result when you run the program the compile would be able to find the file that needs to be executed
Thanks and Regards,<br />Dhaval Shah<br />SCJP 1.4<br />SCWCD 1.4
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.
In my previous post, I placed the > symbol at the wrong place. Sorry about that. I very well understand that I had to CD first. What I meant to write was c:\jdk1.3\bin\rekha progs>javac abc.java
This command gave me the error 'javac' cannot be recognized as an internal or external command.
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
but still i am not able to compile the source code from rekha progs folder.
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...
C:\jdk1.3\bin
...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.
Rekha Anand
Ranch Hand
Joined: Feb 23, 2008
Posts: 36
posted
0
Finally... I got it. I want to thank all forum members who helped me on this.