I am having trouble getting my head around a classpath issue. If i understand correct, when I want to compile a .java file using the java compiler, I need to either be in the directory that the .java file is in or at least add it to my classpath. So I'm a bit confused when I do the following I get a read error;
What I (think) I am doing is adding the directory where the .java file exists to the classpath so the compiler can see the Test.java file to compile it. However I get the following error;
I know that the .java file compiles correctly because I have managed to compile it by invoking the compiler in the same directory as this file. However when I change directories and use the above command it doesn't seem to work. Can someone tell me why??
Joined: Feb 19, 2008
I got happy, I thought you'd answered my question .
If you have the class named samples.quickstart.service.pojo.StockQuoteService that is found in the directory c:/Documents/workspaces/test/src/samples/quickstart/service/pojo, then you have to point the classpath to c:/Documents/workspaces/test/src/. Look at classpath as addresses to class-warehouses. The JVM goes into each appointed warehouse and looks at the package declaration as a specification of what shelf to find the class.
So, you are not to point to the shelf itself, but to the entrance of the storage. And the storage can be a directory, zipfile or jar-file.