error: cannot read testmain.java

the java source file wihtout package name is in d:\prj\source\testmain.java

CLASSPATH =d:\prj\source;C:\eclipse-SDK-3.1.1-win32\eclipse\workspace\EMSchecker;C:\Program Files\Java\jdk1.5.0_05\jre\lib\rt.jar;C:\Program Files\Java\jdk1.5.0_05\jre\bin;C:\Program Files\Java\jdk1.5.0_05\lib\tools.jar;.

c:\Documents and Settings> javac testmain.java

error: cannot read testmain.java

c:\Documents and Settings>javac -sourcepath d:\prj\source testamain.java

error: cannot read testmain.java

d:\prj\source>javac testmain.java

it is ok!

c:\Documents and Settings>java testmain

it is ok!

so, I want to know why the first two cases for javac, the classpath or sourcepath options CANNOT work!!

but the last case for java command tool Can work.

any body can help me, thanks

[852 byte] By [aiwushia] at [2007-10-2 6:09:11]
# 1
Simply, the first 2 things you tried are not valid commands for the situation you described. The explanations are somewhat involved, and already written in detail in the documentation of the javac command. Refer to that doc, it has the answer.
ChuckBinga at 2007-7-16 13:09:49 > top of Java-index,Developer Tools,Java Compiler...
# 2

the first case fails simply bcoz ur source file is in d:\prj\source & ur current directory is "c:\Documents and Settings". so the compiler is not able to find ur source file.

in the second case, -sourcepath option is used to indicate the path where the compiler would find the dependencies java files & not the main java file that u r trying to compile.

if u r still in doubt, refer to this page

http://www.idevelopment.info/data/Programming/java/miscellaneous_java/Using_CLASSPATH_and_SOURCEPATH.html

mobi.v2a at 2007-7-16 13:09:49 > top of Java-index,Developer Tools,Java Compiler...