Not sure if your question is how to program it yourself or if you are referring to how to get Java to automatically check it.
For the second, you can use the security features provided with Java. First, you must digitally sign your jar file (using the jarsigner tool).
Then you must run your program using the security manager ( System.setSecurityManager(new SecurityManager()).
, , , , .
grant signedBy "mrm" {
permission ...
};
Java .