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
DJ_AM_JuiceboxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ajay-SinghCommented:
I believe this should work:
 
java -cp .;C:/libs/MyOtherProjectA/C:/libs/MyOtherProjectB
com.myproject.test.Main
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DJ_AM_JuiceboxAuthor Commented:
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
0
Ajay-SinghCommented:
No space, actually the classpath should be separated by ; in windows.
0
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

DJ_AM_JuiceboxAuthor Commented:
ok so a semicolon between them then, like this?:

    C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB
0
Ajay-SinghCommented:
Yes and add current path in the front
 
..;C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB
0
DJ_AM_JuiceboxAuthor Commented:
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...
0
Ajay-SinghCommented:
> java -cp ..;C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB;  arg1 arg2

should be

java -cp .;C:/libs/MyOtherProjectA/;C:/libs/MyOtherProjectB  arg1 arg2
0
DJ_AM_JuiceboxAuthor Commented:
wow there was so much I was missing to it. I had to just sit down and read the docs.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.