Sign a jar file in JDK 6.0_U32
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Sign a jar file in JDK 6.0_U32

  1. #1
    Join Date
    Jun 2012
    Posts
    2

    Sign a jar file in JDK 6.0_U32

    Hello,
    I am trying to sign a jar file in JDK 6 update 32 and i am getting below error:

    Exception in thread "main" java.lang.NoClassDefFoundError: sun/security/tools/Ja
    rSigner
    Caused by: java.lang.ClassNotFoundException: sun.security.tools.JarSigner
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: sun.security.tools.JarSigner. Program will exit.

    I could not figure out which jar file to include in the classpath. Can someone suggest the correct way of doing it?

    Regards,
    Suresh

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Sign a jar file in JDK 6.0_U32

    It depends on what you are trying to do but a simple way of signing a jar using a key store is
    Code:
    jarsigner -keystore myKeystore MyJar.jar myAlias
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Jun 2012
    Posts
    2

    Re: Sign a jar file in JDK 6.0_U32

    Yes, i am doing as you said. But why i am getting class not found exception? Which jar in should include in my classpath? I tried to look for sun/security/tools/JarSigner class under every jar i can think of within JDK but don't find it anywhere.

    Regards,
    Suresh

  4. #4
    Join Date
    Nov 2006
    Location
    Barcelona - Catalonia
    Posts
    362

    Re: Sign a jar file in JDK 6.0_U32

    $ unzip -l tools.jar | grep -i "jarsigner.class"
    31124 09/10/09 01:47 sun/security/tools/JarSigner.class
    Try tools.jar in $JAVA_HOME/lib using JDK_1_5_22. I'm not sure using Java 6.

    Regards,
    Albert.
    Please, correct me. I'm just learning.... and sorry for my english :-)

  5. #5
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Sign a jar file in JDK 6.0_U32

    Quote Originally Posted by AlbertGM
    Try tools.jar in $JAVA_HOME/lib using JDK_1_5_22. I'm not sure using Java 6.
    Yep, it's in the same place in Java 6.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center