Link to home
Start Free TrialLog in
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

asked on

including a class path

Hi,

I'm trying to run a java application that uses some classes located outside the project tree. I know the app works because I linked it to those external dependencies in eclipse, no problem. I need to run this 'manually' though. This is what I have so far:

    cd "C:\MyProject\bin"
    java -cp . com.myproject.test.Main

It runs, but as soon as it hits any line where I use one of those external classes, the app throws a class loader exception. The other class are located here:

    C:\libs\MyOtherProjectA\cool.class
    C:\libs\MyOtherProjectB\terrific.class

how do I modify my command line to include the path to also include the path of those two class folders?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ajay-Singh
Ajay-Singh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

ASKER

Hi Ajay,

Should there be a space between

    C:/libs/MyOtherProjectA/C:/libs/MyOtherProjectB

otherwise how will it know it's a second path?

Thanks
No space, actually the classpath should be separated by ; in windows.
ok so a semicolon between them then, like this?:

    C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB
Yes and add current path in the front
 
..;C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB
It just doesn't seem to want to work.. I'm running it like:

    java -cp ..;C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB;  arg1 arg2

but it keeps coming back to me saying that it thinks arg1 and arg2 are ALSO class paths to include - not sure what's going on...
> java -cp ..;C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB;  arg1 arg2

should be

java -cp .;C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB  arg1 arg2
wow there was so much I was missing to it. I had to just sit down and read the docs.