Creating a test certificate and signing your jar just involves three simple commands. Following shows the commands needed to firstly create your test certificate and add the certificate (with an alias of myCertAlias) to a keystore (named myKeyStore).
keytool -genkey -keystore myKeyStore -alias myCertAlias
keytool -selfcert -keystore myKeyStore -alias myCertAlias
The above only needs to be done once.
You can then use the keystore to sign your jar using the following command.
jarsigner -keystore myKeyStore jarfile.jar myCertAlias