For your program to be able to use a class of foo.jar, foo.jar must be in the classpath, that's all.
So you'll have to compile your code with
javac -cp foo.jar ...
and to run your code with
java -cp foo.jar:/the/folder/where/your/classes/are ...
or
java -cp foo.jar;c:\the\folder\where\your\classes\are ...
if you're on Windows.
The Java code itself is exactly the same as if the class you want to use was one of your own classes, rather than a class in foo.jar.