File Location Problem
hello this is only a newbie question.
I have organized my java file into a folder and sub folder
e.g.
c:\proj\main.java
c:\proj\frame\frmMain.java
when i compile main.java it doesn't detect frmMain.java
how to specify the location of frmMain.java because in c\c++
you just put #include c:\proj\frame\sample.c but i can't use
import c:\proj\frame\frmMain.java.
Thanks guys.
[435 byte] By [
Ryan747a] at [2007-11-27 11:45:57]

you have to add that path to the class path.
go into the command prompt.
(cd) go into the program folder.
cd c:\proj
java -cp .;frame main
voila.
or alternately from anywhere:
java -cp "c:\proj";"c:\proj\frame" main
(the quotes are only necessary if you have a space in the path)
[edit: or as smithdale mentioned you can add it as a
package]
@TuringPest
if ever I have many sub folders, so I have to add each sub folders to the class path?
e.g.
java -cp "c:\proj";"c:\proj\folder1" main
java -cp "c:\proj";"c:\proj\folder2" main
etc...
If you use packages (like you are supposed to!) then you DONT
have to do that. you can just compile regularly from the package
root.
But for small little things and for the sake of learning you should be
aware of the classpath solution.
But yes, if you are not using packages you have to include EVERY
folder.
java -cp .;folder1;folder2 main
Yea but it really is a BAD habit.
Please trust a person who has had that habit for
WAY too long. It took me forever to break it.