I couldn't find any documentation on how exactly to do this, so here's a sample code:

        ArrayList<String> errors = new ArrayList<String>();

        Project project = RemoteProjectManager.getInstance().getProject(kbHost,
                          kbUserName, kbPassword, kbName, true);
        if (errors.size() > 0) {
            for (String s : errors) {
                log.error(s);
            }
            throw new InitException("Failed to connect to the Knowledge Base");
        }
        knowledgeBase = project.getKnowledgeBase();

[They didn't provide documentation, but you can still digg their unit tests...]