Classpath override not working correctly in command prompt?
I am trying to run my program in command prompt using -classpath override. Take a look at what i tried here, and what resulted when I tried to give the classpath from a higher root directory. I am wondering why it can't find the file.
Code :
C:\Program Files\Java\src\com\scjaexam>dir
Volume in drive C is OS
Volume Serial Number is 8873-03A4
Directory of C:\Program Files\Java\src\com\scjaexam
12/06/2011 01:38 PM <DIR> .
12/06/2011 01:38 PM <DIR> ..
12/06/2011 01:42 PM <DIR> ex2_1
11/17/2011 12:49 PM <DIR> tutorial
0 File(s) 0 bytes
4 Dir(s) 112,734,724,096 bytes free
C:\Program Files\Java\src\com\scjaexam>cd ex2_1
C:\Program Files\Java\src\com\scjaexam\ex2_1>dir
Volume in drive C is OS
Volume Serial Number is 8873-03A4
Directory of C:\Program Files\Java\src\com\scjaexam\ex2_1
12/06/2011 01:42 PM <DIR> .
12/06/2011 01:42 PM <DIR> ..
12/09/2011 11:14 AM 82 iterator.java
1 File(s) 82 bytes
2 Dir(s) 112,734,724,096 bytes free
C:\Program Files\Java\src\com\scjaexam\ex2_1>javac -cp iterator.java
javac: no source files
Usage: javac <options> <source files>
use -help for a list of possible options
C:\Program Files\Java\src\com\scjaexam\ex2_1>javac -cp . iterator.java
iterator.java:1: ';' expected
package com.scjaexam.ex2_1
^
1 error
C:\Program Files\Java\src\com\scjaexam\ex2_1>javac iterator.java
iterator.java:1: ';' expected
package com.scjaexam.ex2_1
^
1 error
C:\Program Files\Java\src\com\scjaexam\ex2_1>cd..\..\..
C:\Program Files\Java\src>javac -cp .\com\scjaexam\ex2_1 iterator.java
javac: file not found: iterator.java
Usage: javac <options> <source files>
use -help for a list of possible options
C:\Program Files\Java\src>
Re: Classpath override not working correctly in command prompt?
Quote:
I am wondering why it can't find the file.
What is 'it' and what is the 'file'?
I see that the javac program found some syntax errors in the iterator.java file
Then you changed directory away from where the source file was and javac could not find it any more.
The classpath is NOT for finding source files. It's for finding .class files.
Re: Classpath override not working correctly in command prompt?
Thank you for pointing this out.
My textbook says that packaging is not a container for classes, like namespaces, but rather defines where they are located. So you must have a package statement in files that are to be imported?