Example below creates CompositeName that comprise of LDAP URL.

Java Code:
String url = "ldap://localhost:389/cn=homedir,cn=Jon%20Ruiz,ou=people,o=JNDITutorial";

// Create a CompositeName in which the first component is a URL string
Name name = new CompositeName().add(url);

// Add the other components
name.add("tutorial").add("report.txt");

// Perform the lookup by using CompositeName
System.out.println(ctx.lookup(name));