Like this.
In other words, you make a GET request to the Server sending your Client-ID from your registered application (here) , and you’ll receive a response structured like this:
If stream’s offline:
{
"stream":null
}
Otherwise:
{
"stream": {
...
},
"channel": {
...
}
}
}
You should check Twitch API docs for more.
If you want to know how to do this specifically in Java, you should learn how to make requests to a generic Server in Java first.