If I have a component id (for example tcm:9-123), is there a way to get its content? How can this be achieved in java ?
In general, you can’t get the content of Components separately on the CD side.
You can get the content of a Dynamic Component Presentation, though. In DXA, DCPs are represented as Entity Models with an ID like
<ComponentID>-<TemplateID>. For example:
123-234 for a DCP of Component
tcm:x-123 rendered with Template
You can use
ContentProvider.getEntityModel for this purpose.