Have a look at this example included in the SDK.
There is more info at dev.splunk.com also.
Here is a pseudocode excerpt copied from the above link showing usage of the Java SDK to execute a Splunk search and obtain the results:
Service service = Service.connect(...);
Job job = service.getJobs().create("search * | head 10")
while (!job.isDone()) {
Thread.sleep(2000);
job.refresh();
}
InputStream stream = job.getResults();