Another option is WebDav, which is supposed to be somewhat faster than RMI, though not as fast as the native interface:
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.apache.jackrabbit.commons.JcrUtils;
public class main {
/**
* @param args
*/
public static void main(String[] args) throws Throwable{
String url = "http://localhost:8080/server";
System.out.println("Connecting to " + url);
Repository repository = JcrUtils.getRepository(url);
SimpleCredentials creds = new SimpleCredentials("admin",
"admin".toCharArray());
Session jcrSession = repository.login(creds, "default");
System.out.println("Login successful, workspace: " + jcrSession.getWorkspace());