Forum Stats

  • 3,825,244 Users
  • 2,260,486 Discussions


Getting security exception

Anthony747 Member Posts: 1


I am new to Java and learning the Java security. Following the java documentation tutorial ( ) on creating special permission, I get an java.lang.SecurityException when I reach the end of the tutorial at ( ). Here is the content of the kim.policy file:

keystore "kim.keystore";

grant SignedBy "terry" {



      "SoccerGame", signedBy "chris";


grant SignedBy "chris" {

  permission java.util.PropertyPermission

    "user.home", "read";


      "${user.home}${/}Downloads/TMP/scoreFile", "read,write";



      "*", signedBy "chris";


The stack trace:

Exception in thread "main" java.lang.SecurityException: class "HighScore"'s signer information does not match signer information of other classes in the same package

        at java.base/java.lang.ClassLoader.checkCerts(

        at java.base/java.lang.ClassLoader.preDefineClass(

        at java.base/java.lang.ClassLoader.defineClass(

        at java.base/

        at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(

        at java.base/jdk.internal.loader.BuiltinClassLoader$

        at java.base/jdk.internal.loader.BuiltinClassLoader$

        at java.base/

        at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(

        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(

        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(

        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(

        at java.base/java.lang.ClassLoader.loadClass(

        at SoccerGame.setHighScore(

        at SoccerGame.main(

For the sake of simplicity, I have removed all the package names from the source code (i.e. and I renamed the class ExampleGames to SoccerGames. All the respective keys, keystores and certificates where generated according to the tutorial, however, I feel the security exception is due to the fact that jar files in this tutorial is signed by two different signers (according to the tutorial of course).

In addition, when I try to load the kim.policy into policytool, it can not find the class HighScorePermission which is located in terry.jar according to tutorial. From the windows command prompt, I have set the classpath to include the two jar file (terry.jar and hs.jar) in this tutorial.

I have invested a great deal to troubleshoot these two problems, alas reached the end of the rope and hopeless. At this junction, any insights, help or idea will be so great.