How to set kubernetes secrets from a java application

Hi, i had a requirement where in i have a java code which checks if my password has been rotated or not, and the moment its rotated, i need to set it to kubernetes secrets.
I was thinking to create a cron job which keeps on repeatedly checking for password rotation and once done, it sets it to kubernetes secrets, Is this possible to do ? can someone suggest a better approach ?
Thanks!