The code you have picked up from Stanford NLP website performs all the annotations on the text variable. In order to perform specific annotations you have to change the code accordingly.
To perform tokenization, this would be sufficient
Properties props = new Properties();
props.put("annotators", "tokenize");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation document = new Annotation(text);
pipeline.annotate(document);
for (CoreLabel token: document.get(TokensAnnotation.class)) {
String word = token.get(TextAnnotation.class);
}
This line of code would return Null if annotators doesn't include Sentence Splitter("ssplit")
document.get(SentencesAnnotation.class);
And so you were encountering NullPointerException.