Not sure if I understand what you mean. But you should explicitly provide a JavaAction with parameters in your microflow. It's not possible to 'just' get any variable available.
If you want to pass an object, but don't want to specify of which entity, as any object will do, you can design a JavaAction using a TypeParameter, then you do need to specify whether it's a single object or a list of objects, but don't need to specify for which entity. See the objectIsNew JavaAction from the CommunityCommons as example.
Good luck!
You need to define a type parameter.
https://docs.mendix.com/refguide/java-actions/#type-parameters
Then use this as the type of an Object parameter.
That allows to pass arbitrary objects to a java actions.
Create a TypeParameter in your Java action and you can pass any type of object to this argument.