Why some codes can be executed by creating an object file through compiler while some codes need an interpreter to be executed?

We can execute a c/cpp file by creating an object file through compilation.But why do we need to pass java bytecodes through an interpreter to execute them?What’s the differentiating feature that makes interpreter necessary to execute java bytecoes?