If you create an application bundle to start a Java application as a regular Mac app, you will get a message that the application is damaged when you try to run it on Mac OS Mountain Lion with GateKeeper active.
The error is caused by the fact that the Java stub application is signed by Apple, and Apple’s signature will not be valid for your application.The codesign tool will give the following message:
codesign -d MyJavaApplication.app
MyJavaApplication.app: invalid signature (code or signature have been modified)
The best solution is to sign your application with your Apple Developer key, but if you do not have one you can still sign your application with an ad-hoc key, and replace the Apple signature that will cause this message. To do so run codesign with the following options:
codesign -s – –force MyJavaApplication.app
The user will still have to allow running the application the first time by using the right-click (Co …
Source: Mac OSX Hints