Components don't have URLs, so that might be a bit tricky to achieve.
Pages do have URLs, and you can use the PageFactory
class to find them, something along these lines:
PageMetaFactory factory = new PageMetaFactory(publicationId);
PageMeta meta = factory.getMetaByUrl(publicationId, "/my/url");
List<ComponentPresentationMeta> cpMetas = meta.getComponentPresentationMetas();
This will contain a list of all component presentations for a given page. You can use cpMeta.getComponentId()
to get the component ID of the component presentation in question.
You may want to start asking Tridion questions here: http://tridion.stackexchange.com