E.g., a simple project with no outside deps might be like (and I typed this out on my phone):
java_binary(name = "grep_bin", srcs = ["grep_main.java"], deps=["grep_lib"])
java_library(name="grep_lib", srcs =["grep_lib.java"])
Things get more opinionated when you pull in outside libraries, but even then bazel makes it fairly painless and integrates with other build systems where needed.
Take a look at the docs here for more info: https://docs.bazel.build/versions/master/be/java.html
It was build to solve a problem of building software at scale across multiple languages, platforms in a single monorepo. And it's great at that. It becomes limiting as your use-case steps away from this "monorepo, across languages" approach.
For example the Scala rules have specs2 (a unit testing lib/harness/framework/thing) [1]
I have no idea how this all works in practice.
[0] https://github.com/bazelbuild/bazel/blob/master/site/docs/ru...
[1] https://github.com/bazelbuild/rules_scala/blob/master/exampl...