| Author |
add all subfolders to classpath
|
seetharaman jayaraman
Ranch Hand
Joined: Feb 18, 2008
Posts: 42
|
|
Hi all,
I have classes like below:
c:\proj\main\p1\Class1.class
c:\proj\main\p1\Class2.class
c:\proj\main\p2\Class3.class
c:\proj\main\p2\Class4.class
c:\proj\main\p3\Main5.class
here main, p1,p2 and p3 are packages. if i want to modify classpath for the above classes, i need to do like this:
set classpath=%classpath%;c:\proj\main\p1\;c:\proj\main\p2\;c:\proj\main\p3\;
Here all p1,p2 and p3 are subpackages of "main" package. And when the number of subpackages becomes large, the classpath becomes a big list (like a paragraph!!). Is there any way simplify this i.e to include all subpackages of main package.
Thanks
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
So, class Class1 is in a package called main.p1?
If so, you don't need to add all those sub folders to the class path - c:\proj\ is enough. When the JVM needs to load class main.p1.Class1, it will try looking for a file main\p1\Class1.class relative to all folders in the class path. So if your class path includes ".", "D:\" and "c:\proj\", it will try ".\main\p1\Class1.class" first, "D:\main\p1\Class1.class" next and finally ""c:proj\main\p1\Class1.class".
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
seetharaman jayaraman
Ranch Hand
Joined: Feb 18, 2008
Posts: 42
|
|
I tried many ways. By fluke, a dot (".") solved the problem. i.e, the main package is "main" under c:\proj\ folder. p1, p2 and p3 are under this "main" package. I set classpath like the one below (added a dot after "c:\proj\") which solved the problem:
set classpath=%classpath%;c:\proj\.;
This includes all sub folders (sub packages) to the classpath.
Also thanks Rob Prime.
|
 |
 |
|
|
subject: add all subfolders to classpath
|
|
|