You can throw a MendixRuntimeException from Java:
throw new MendixRuntimeException();
You can then do the error handling from Mendix. For example, Show Message action uses the default Mendix localization based on user settings:
Error details are available in the $latestError variable which you can optionally use in Mendix to configure the error handling further.