Follow the documentation.
https://docs.mendix.com/howto/logic-business-rules/extending-your-application-with-custom-java
Class as in CSS?
Then this might help
https://docs.mendix.com/howto/front-end/customize-styling-new
Class as in entity
https://docs.mendix.com/refguide/domain-model