Jarsigner is messing up my manifest!!

There was another topic posted about a year ago where someone was having the exact same problem as I am, but no one replied to his question, so hopefully someone out there has a solution to this, as I am stumped..
I have a manifest file for my application that specifies a main-class as well as class-path. After I use the Jarsigner, those attributes are wiped out!!! This is not good. I have done this before and have not had a problem, and for the life of me I cannot figure out what I am doing different.
Any suggestions would be appreciated.

I posted a bunch of information about a similar problem here:
http://forum.java.sun.com/thread.jsp?forum=38&thread=275890
Randy

Similar Messages

  • Missing signed entry in resource : urgent

    Hi
    While trying to acces my apllication on Tomcat 4.0 Servber I get this error
    Missing signed entry in resource: http://localhost:8080/Graf/GZ.jar
    exception is
    JNLPException[category: Download Error : Exception: null : LaunchDesc: null ]
    at com.sun.javaws.security.SigningInfo.checkSigning(Unknown Source)
    at com.sun.javaws.cache.DownloadProtocol$RetrieveAction.actionDownload Unknown Source)
    at com.sun.javaws.cache.DownloadProtocol.doDownload(Unknown Source)
    at com.sun.javaws.cache.DownloadProtocol.getResource(Unknown Source)
    at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source)
    at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source)
    at com.sun.javaws.Launcher.downloadResources(Unknown Source)
    at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
    at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
    at com.sun.javaws.Launcher.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    My jnlp file looks like
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp codebase="http://localhost:8080/Graf/" href="GrafZeppelin.jnlp">
    <information>
    <title>Graf Zeppelin</title>
    <vendor>P&G</vendor>
    <homepage href="GrafZeppeling.html"/>
    <description>Graf Zeppelin</description>
    <description kind="short">Grap Zeppelin Application to display Graf Zeppelin</description>
    <description kind="one-line">Graf Zeppelin System</description>
    <description kind="tooltip">P&G</description>
    <icon href="images/gpblogo.jpg"/>
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.3+" initial-heap-size="24m" max-heap-size="256m" />
    <jar href="y.jar"/>
    <jar href="GZ.jar"/>
    </resources>
    <application-desc main-class="pathways.GZBase">
    </application-desc>
    </jnlp>
    I have already done sigining of jar thru these commands
    keytool -genkey -keystore myKeystore -alias myself
    keytool -list -keystore myKeystore
    jarsigner -keystore myKeystore test.jar myself
    Can anypone tell me if something elase also needs to be done for this to make it work.I mean some other settings or something which I might be missing while deploying it.
    Thanks
    Sidh

    I just got done spending some "quality time" (about 2 days worth) with jarsigner and Java Web Start to figure out a certificate problem, and I thought I'd share my findings to save others a bunch of time.
    I have a JWS application that has two custom built jars and several third party jars. I'm looking to run it in "unrestricted" mode which means that all of the jars need to be signed. The building and signing went fine but I ran into the problems often mentioned in this forum of exceptions being thrown from the bowels of JWS while it was trying to launch my application.
    I ran into a few different problems at different times. One was getting this exception during launch:
    JNLPException[category: Download Error : Exception: null : LaunchDesc: null ]
         at com.sun.javaws.security.SigningInfo.checkSigning(Unknown Source)
         at com.sun.javaws.cache.DownloadProtocol$RetrieveAction.actionDownload(Unknown Source)
         at com.sun.javaws.cache.DownloadProtocol.doDownload(Unknown Source)
         at com.sun.javaws.cache.DownloadProtocol.getResource(Unknown Source)
         at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source)
         at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source)
         at com.sun.javaws.Launcher.downloadResources(Unknown Source)
         at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
         at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:536)
    Another was an exception that included the message "Missing signed entry in resource".
    The source of all of these problems was an incorrectly created/signed jar file. My problems occured with jakarta-ojb-0.9.7.jar (Jakarta's OJB package), but I believe that it can happen with any jar file.
    First let me review what I found out about how the jar building and signing is done. When you sign a jar file with jarsigner, it creates signature files which it puts in the META-INF directory of the jar file. For example if you sign a jar file with the alias "foo", it will add files FOO.SF and FOO.DSA to the META-INF directory (your extensions may be slightly different depending on what kind of keys you have).
    jarsigner also creates a new manifest file META-INF/MANIFEST.MF. For my jar file, before I signed it the MANIFEST.MF contained only this:
    Manifest-Version: 1.0
    Created-By: Apache Ant 1.5
    Name: ojb
    Class-Path:
    After I signed it, the file had 675 entries in it like this:
    Manifest-Version: 1.0
    Created-By: Apache Ant 1.5
    Name: org/apache/ojb/broker/metadata/RepositoryTags.class
    SHA1-Digest: bX/beup+4fwyuMQIF9sz55wz3Zk=
    Name: org/apache/ojb/odmg/states/ModificationState.class
    SHA1-Digest: xl0iS4ojhVh8pHwzabKK9T2ouLg=
    Name: org/apache/ojb/jdo/JDOTransaction.class
    SHA1-Digest: Z/EV2WgDPVbHkY3D78mOIjLyLI0=
    Name: org/apache/ojb/broker/util/pooling/WrappedConnection.class
    SHA1-Digest: B3r6HwsWePdNkMYh8jIeBmfjrUc=
    Here is where the problems begin. Here is one known bug that I did not have but you should be aware of, which has to do with paths that have 133 or 134 characters:
    http://developer.java.sun.com/developer/bugParade/bugs/4357504.html
    Another problem is as follows. When JWS reads the manifest file from each jar file, it iterates through all of the manifest entries and for each one, verifies that there is an entry in the jar file for it. Here is the code decompiled from javaws version 1.2 to give you an idea:
    Manifest manifest = jarfile.getManifest();
    Set set = manifest.getEntries().entrySet();
    for(Iterator iterator = set.iterator(); iterator.hasNext();)
    java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next();
    String s1 = (String)entry.getKey();
    if(jarfile.getEntry(s1) == null)
    throw new JARSigningException(url, s, 4);
    The problem is that the manifest can sometimes contain entries that are intended as headers like this:
    Name: ojb
    Class-Path:
    This fragment was created by the application that created the original jar file (ant), and was included in the new manifest file created by jarsigner. Inexplicably, this fragment was about one third the way down the 2228 line file, rather than at the top where you would expect it.
    When JWS iterates through the manifest entries, it finds this one named "ojb", and then it tries to find an entry in the jar file with this key, and fails, which throws the JARSigningException, which causes the application launch to fail. Unfortunately JWS doesn't give you any of this detail in the error message, I had to discover this through a lot of sleuthing (and so will yoU!).
    JWS just uses the java.util.jar classes to read the jar and manifest files, so it is simple to write a small utility that reads jar and manifest files and reports on them to help you identify problems like this. Note that using the -verify flag to jarsigner doesn't find many problems. Below is a utility I wrote called GrokJar:
    import java.io.*;
    import java.util.*;
    import java.util.jar.*;
    public class GrokJar {
    public static void main(String s[]) {    
    String action = s[0];
    if(!action.equals("-j") && !action.equals("-m")) {
    System.err.println("Usage: GrokJar [-j | -m] file");
    System.err.println("\t-j grok a jar file");
    System.err.println("\t-m grok a manifest file");
    System.exit(0);
    String pathname = s[1];
    if(action.equals("-j")) {                             
    try {                                                
    File jarFile = new File(pathname);
    JarFile jar = new JarFile(jarFile);
    Manifest manifest = jar.getManifest();
    Set set = manifest.getEntries().entrySet();
    System.out.println("Manifest has " + set.size() + " items");
    for(Iterator iterator = set.iterator(); iterator.hasNext();) {
    java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next();
    String key = (String)entry.getKey();
    if(jar.getEntry(key) == null) {
    System.out.println("Can't get entry from jar for key \""+key+"\"");
    } catch(Throwable t) {
    t.printStackTrace();
    else if(action.equals("-m")) {                     
    try {              
    Manifest manifest = new Manifest(new FileInputStream(pathname));
    Set set = manifest.getEntries().entrySet();
    System.out.println("Manifest has " + set.size() + " items");
    } catch(Throwable t) {
    t.printStackTrace();
    This utility reported the following for my jar:
    Manifest has 675 items
    Can't get entry from jar for key "ojb"
    The solution to my problem was as follows:
    1) First, make a copy of the unmolested jar file before you mess around with it (by default jarsigner modifies a jar file in place)
    2) Sign the jar file with jarsigner
    3) Run the GrokJar utility to discover any errant keys
    4) If there are errant keys, un-jar the jar file into a temporary directory
    5) Edit the file META-INF/MANIFEST.MF to remove the errant keys
    6) Create a new jar file. Note that simply "jar cf" won't work. By default, the jar utility creates a new manifest file, which will overwrite the one you just edited. you need to either include the "m" parameter and specify your manifest file, or the "M" file so it won't create its own manifest file and it will use the one you edited.
    7) Sign the jar file again with jarsigner. The reason is that jarsigner creates a signature for every entry in the manifest. If you sign it and then edit the manifest, the signature and manifest won't match. So you need to sign it again.
    8) Run GrokJar against it again, and you should see a different number of manifest entrieS (not zero), and no errant keys.
    That is what did it for me. Your mileage may vary. Here are some other links to good information that I found:
    http://www.vamphq.com/download/jwsfaq.pdf
    http://developer.java.sun.com/developer/bugParade/bugs/4625532.html
    http://developer.java.sun.com/developer/bugParade/bugs/4357504.html
    http://forum.java.sun.com/thread.jsp?thread=206075&forum=38&message=697559
    Best of luck!
    Randy

  • "Unable to parse the opf file" of my book, what to do?

    We have created a neat little eBook with iBooks Author, following all the specifications, keeping an eye on memory limits, etc., and using some of the widgets, but we are getting an error message when we try to submit the book through iTunes Producer, so we can't cross the finish line (after which there is a beer waiting, but not yet.)
    This eBook process has taken us about one year to complete.
    This is the error message that appears on the system: "Error ITMS-9000 'Unable to parse opf file container.xml' at Book.
    I know a little bit about EPUBs, and I know this is not a playground-variety error message. So I need help.
    There are a few threads out there that address this issue (but not really, more like people drowning and crying "help" while the sea whirl drags them down to the depths).
    Here is the issue: Our file is not a standard EPUB file that you can whip up with Sigil, and then mess with the manifest; it is a fully loaded peacock authored and designed with iBooks Author, complete with sound files, widgets, etc. Hence my worry.
    Any suggestions so that I can sleep tonight? They would be much appreciated.

    Yep, i just did it again. The entire scroll-bar widget, complete with formatted text, graphics, etc., pasted itself nicely in another book. Two different files, the same widget.
    I use the scroll-bar widgets for most of my texts. (I have audio buttons on the side, and the scripts are within the widget, to the side). My only text is within widgets, and text boxes, naturally. 
    I am following your recommendation: cleaning files, etc. I am remaking the book anew. I need to convince the EPUB bot or whatever that my file looks and works nicely on all my devices. You would expect an error message when previewing the book: 'Hey Amigo, your file is flawed, stop working on it, and get back to the drawing board." Should be able to try again next Monday.

  • Jar filing

    Alright I'm running into this crazy exception when running my compiled java jar executable file....
    I'm using JBuilder and I have added some libraries my org uses, which are other jar files. When I run my app from JBuilder it works correctly, all the classes are being imported correctly and everything. However, when I compile my application, it compiles but when I run it, it gives me a NoClassDefFound for the other Classes I'm using which I have imported into my Required Library. Many people have told me to mess with my manifest file, others have told me to set my classpath's in a batch file. Basically, I wanna include some jar files, that I call in my app into my jar or exec file. I've tried editing my manifest file, but I couldn't get that to work, I've also tried physically moving the jar file into my app's jar file, but nothing happens. Any suggestions?

    Duplicated (and answered) here: http://forum.java.sun.com/thread.jspa?threadID=767432&messageID=4374910#4374910

  • My JAWS app seems to work, but dies quickly

    Hello All -
    Firstly, here is a link to my app: http://www.xurg.com/jaws/apps/index.html
    I have been messing with JAWS and JNLP all day. My server is set up right and everything. I created a JAR file with my app inside and made a link to my JNLP file. JAWS told me I had many errors all day, but I think I've fixed them all. If you run my app you'll see it apears to load fine, but then after loading nothing happens! I don't know where to go from here. Below are sniplets from my related files:
    sgp.jnlp<?xml version="1.0" encoding="utf-8"?>
    <!-- JNLP File for SGP Application -->
    <jnlp
      spec="1.0+"
      codebase="http://www.xurg.com/jaws/apps/"
      href="sgp.jnlp">
      <information>
        <title>SGP Application</title>
        <vendor>XURG Games 2004</vendor>
        <homepage href="docs/sgp/index.html"/>
        <description>SGP Game Demo</description>
        <description kind="short">A demo of a game using the Swing Graphical User Interface.</description>
        <icon href="images/sgp.gif"/>
        <offline-allowed/>
      </information>
      <resources>
        <j2se version="1.4+"/>
        <jar href="jar/sgp2.jar"/>
      </resources>
      <application-desc main-class="Games/SGP/SGP"/>
    </jnlp>/META-INF/MANIFEST.MF
    Main-Class: Games/SGP/SGP
    I have tried messing with the Manifest.mf file a bit. I've put main, SGP, and the full package path to SGP (Games/SGP/SGP) where SGP is the file with my main.
    Any Suggestions? Thanks in advance!

    Your game seems to work just fine (I can't test it to much, I'm at work ;-)
    Failed to load Main-Class manifest attribute from
    sgp2.jar
    my jar file is setup like:
    /T3/*
    SGP files
    /META-INF/MANIFEST.MF
    hmmmmmmmDid you try : java -hjar sgp2.jar Games.SGP.SGP
    btw, I would use Games.SGP.SGP in the main class attribute of the JNLP file...

  • JAVA command line options -cp and -jar don't work together?

    Running JSDK 1.4.2 under Windows. I have a Java application that tries to dynamically load a class name that the user enters as follows:
    try {
    classResult = java.lang.Class.forName(strFilterName);
    catch (ExceptionInInitializerError e) {
    strErrorMessage = "ExceptionInInitializerError loading class: " + strFilterName;
    catch (LinkageError e) {
    strErrorMessage = "LinkageError loading class: " + strFilterName;
    catch (ClassNotFoundException e) {
    strErrorMessage = "ClassNotFoundException loading class: " + strFilterName;
    This works fine if the classes that make up my application are left as class files in the classpath, but fails to work if they have been collected and run from a JAR file. Note: I can even dynamically load the class when running from the JAR file, if the class I'm trying to load is within that JAR file too. The problem really occurrs when the dynamically loaded class is located someplace else in my classpath. I've tried using various combinations of the "-cp" and "-jar" Java command line options - but when loading and running from a JAR file - the "-cp" parameters seem to be ignored. Is this a bug? Has anyone ever seen this before?
    I run my program from the JAR file using this command:
    java -cp .;e:\entmgr\filters -jar EntMgr.jar
    Where "e:\entmgr\filters" is where the class I'm trying to dynamically load is. (This class has no package name, but loads perfectly as long as I'm not running the application from the JAR file). The class name specified by the user has to be fully specified with a package name (if it has one).
    I have tried forcing the "java.lang.Class.forName(strFilterName);" call to use the system class loader, the parent of the system class loaded, and even the null bootstrap class loader - all with no success.
    I am suspecting that the class loader that is loading and running my main program from the JAR file, is just not paying any attention to the "-cp" parameter when the "-jar" parameter is present. Indeed, I have never seen any change in the failure, no matter what I put in the "-cp" parameter when using the JAR file.
    When I run this without using the JAR file, here is the command I execute:
    java -cp .;davidp\snmp;filters davidp.snmp.EntMgr
    Where this is executed in a directory that has a "filters" and "davidp\snmp" directory. In this case, because the "filters" directory is in my class path - I can dynamically load my class from it using just its simple name (i.e. "TestTrapFilter").
    So, is there some bug that precludes the "-cp" parameter from working correctly when the "-jar" parameter is used? Is there some other way to initialize or set up the classloader I'm using, so it can find things outside of the JAR file I'm running from? I would hope that it is possible to get the same behavior from my program, no matter if it is run from a JAR file or not.
    Thanks for any assistence!
    Dave

    These posts are pretty old, but this page came up in a google search while I was having the same problem, so I thought I would throw my own (Later found) solution in.
    The -cp and -jar options did not work together for me, but I later learned that they didn't really have to (and you don't have to mess with jar manifest files).
    While on the command line, if you want to set a specific class path and also run a jar, all you need to do is add the jar to whatever extra class path you need to use in the -cp <arg>, and then specify which class you want run from inside the jar.
    IE:
    java -cp <YourSpecialClasspath>: <PathToJar> <ClassToRunInsideOfJar>
    in my case it was like:
    java -cp /home/user/WebRCP.jar:./StandaloneInstaller.jar InstallLoader
    Remember to put a ":" in between the two arguments for the class path (-cp).
    Hope this helps someone in the future,
    -Josh

  • Interesting Jar Signing Issue

    I started out creating my key with:
    keytool -genkey -keystore myKeystore -alias newKey
    keytool -genkey -selfcert -alias newKey -keystore myKeystoreI then proceeded to successfully sign and verify 8 jar files using:
    jarsigner -keystore myKeystore MyClass.jar newKey
    jarsigner -verify MyClass.jarOn the 9th and 10th jar files the verify came back with this error:
    jarsigner: java.io.IOException: invalid manifest formatOn the 9th jar file I un-jarred it and then re-jarred it again. I then signed it and verified it properly.
    It is the 10th jar file that I cannot verify the signature for the life of me. I have gone though all of the above processes multiple times and have accomplished nothing besides losing a bit of hair! I do not understand this error because I am not modifying the manifest file whatsoever. It is just the plain jane vanilla manifest file that the jar command creates for you.
    Basically I will sign the jar file and everything appears to be ok. When I verify I get the invalid manifest format error. If I try to sign the jar file again even with a different key I also get the invalid manifest error. It is almost as if jarsigner is trashing my manifest file. What should I do?!?
    Help would be appreciated!
    Phil

    I was getting the IOException as you have mentioned above. I took the manifest from the signed jar and found that it didn't like the blank lines between some of the class and hash digital signature entries. These blank lines are not supposed to be there but it was jarsigner putting them there. The way I found out about these lines was by using my own modified Java VM and print out line numbers from the manifest file. Anyway, I couldn't put the corrected file back into the Jar as it would mean I wouldn't be able to verify the jar as it would now be deemed tampered with.
    I solved my problem by using a different developer's machine and jdk. I was using JDK 1.3.0 c and the other developer's version was JDK 1.3.1. His environment made it all work first time. I suggest you try a different environment (ideally JDK 1.3.1 properly installed and without any other JDKs installed) just as a check.
    I hope this helps.

  • Unable to get jarsigner to sign jar file using pkcs11 smartcard

    I'm using a JDK jdk1.6.0_14 with a datakey smartcard with the below info in pkcs11.cfg file:
    name = DK330
    library = c:\windows\system32\dkck232.dll
    I have also configured the java.security file to include the security.provider.10=sun.security.pkcs11.SunPKCS11 c:/pkcs11.cfg
    I have my environment set for the below to keep it simple as possible:
    JAVA_HOME=C:\Program Files\Java\jdk1.6.0_14
    CLASSPATH=C:\Program Files\Java\jdk1.6.0_14\lib
    PATH=C:\Program Files\Java\jdk1.6.0_14\bin;c:\windows;c:\windows\system32
    1) I am able to Confirm that the secret key is present in the keystore
    keytool -v -list -keystore NONE -storetype PKCS11 -storepass xxxxxx
    Keystore type: PKCS11
    Keystore provider: SunPKCS11-DK330
    Your keystore contains 1 entry
    Alias name: CS.NOLSC.002's U.S. Government ID
    Entry type: PrivateKeyEntry
    Certificate chain length: 1
    Certificate[1]:
    Owner: CN=CS.NOLSC.002, OU=USN, OU=PKI, OU=DoD, O=U.S. Government, C=US, OU=PKI, OU=DoD, O=U.S. Government, C=US
    Issuer: CN=DOD CA-14, OU=PKI, OU=DoD, O=U.S. Government, C=US
    Serial number: 3e8e
    Valid from: Mon Feb 05 14:53:22 EST 2007 until: Thu Feb 04 14:53:22 EST 2010
    Certificate fingerprints:
    MD5: 9D:34:AF:D8:DE:18:15:78:D6:88:3D:37:83:FA:DC:E8
    SHA1: 8A:BB:39:D5:2B:45:F7:CE:A3:93:C5:71:5C:36:DC:FE:3F:B4:7D:9A
    Signature algorithm name: SHA1withRSA
    Version: 3
    Extensions:
    #1: ObjectId: 2.5.29.15 Criticality=true
    KeyUsage [
    DigitalSignature etc
    2) When I try to sign the applet using the below commands I get the same errors:
    command 1:
    jarsigner -keystore NONE -storetype PKCS11 -providerClass sun.security.pkcs11.SunPKCS11 -providerArg ${java.home}/lib/security/pkcs11.cfg sfilechooser.jar "CS.NOLSC.002's U.S. Government ID"
    I get this error::
    jarsigner error: java.security.ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_ATTRIBUTE_TYPE_INVALID
    command 2:
    jarsigner -verbose -keystore NONE -storetype PKCS11 -storepass xxxxxx sfilechooser.jar "CS.NOLSC.002's U.S. Government ID"jarsigner error: java.security.ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_ATTRIBUTE_TYPE_INVALID
    I can also confirm the jar file that I'm trying to sign is unsigned using the below command without problem.
    C:\Program Files\Java\jdk1.6.0_14\bin>jarsigner -verify -verbose -certs -keystore NONE -storetype PKCS11 sfilechooser.jar
    Enter Passphrase for keystore:
    0 Wed Jul 08 09:36:06 EDT 2009 META-INF/
    71 Wed Jul 08 09:36:06 EDT 2009 META-INF/MANIFEST.MF
    4227 Tue Jun 09 09:56:20 EDT 2009 DirList.class
    0 Wed Jul 08 09:29:52 EDT 2009 FileChooserPackage/
    4728 Tue Jun 09 09:56:20 EDT 2009 FileChooserPackage/DirUtil.class
    809 Fri May 29 13:05:42 EDT 2009 FileChooserPackage/FileChooserBean$AWTFileDialogThread.class
    765 Fri May 29 13:05:42 EDT 2009 FileChooserPackage/FileChooserBean$AWTSaveDialogThread.class
    819 Tue Jun 09 09:56:20 EDT 2009 FileChooserPackage/FileChooserBean$FileChooserBeanThread.class
    1015 Tue Jun 09 09:56:20 EDT 2009 FileChooserPackage/FileChooserBean$FormsDecoderException.class
    815 Tue Jun 09 09:56:20 EDT 2009 FileChooserPackage/FileChooserBean$SaveFileChooserThread.class
    17198 Tue Jun 09 09:56:20 EDT 2009 FileChooserPackage/FileChooserBean.class
    s = signature was verified
    m = entry is listed in manifest
    k = at least one certificate was found in keystore
    i = at least one certificate was found in identity scope
    jar is unsigned. (signatures missing or not parsable)
    ======================================
    What could be my problem to get my applet signed? I'm at a loss.

    I found the problem.
    I was able to use jarsigner correctly after I backed off on the GemPlus driver version from v4.7.062 file name dkck232.dll to the previous version of dkck201.dll at v4.7.062.

  • Manifest and classpath frustration

    I have a very simple standalone application. It is not an applet - it's a simple command line program that parses an XML stream and stores the results in a database. This app depends on a ton of external jar files. I would like to be able to build and run this thing - on different platforms - without having to mess with a bat or sh script. From perusing the web, it seems like I should be able to do this with a custom manifest file ... but I can't seem to get it to work. I keep getting a class not found error. In a nutshell, my jar looks like this
    lib
    com
    META-INF
    Insid the lib directory are around a dozen jar files
    Inside the com directory are all my class files
    Inside META-INF is the manifest file.
    My manifest file looks like this:
    Main-Class: com.mainClass.RunMe
    Class-Path: lib/jarOne.jar
    **lib/jarTwo.jar
    **lib/jarThree.jar
    Note that the *'s indicate spaces and I do have a blank line at the end of file.
    When I try to execute using:
    java -jar myJar.jar
    I continually get class not found errors. If I run in verbose mode, I can see that my classes aren't getting loaded.
    Can I do what I'm trying to do? Any pointers would be greatly appreciated as I'm running out of ideas and patience.
    THanks

    This isn't always legal. You can't "legally" assume you can extract any commercial jar file and bundle it with your app. If everything is open-source then there should be no problem. But for commercial apps, this wont work, at least legally.
    There are two solutions that work best. One is to use an installer that provides an executable launcher (.exe on windows, .sit on mac, etc). This will provide a setup.exe (or setup.sit or setup.sh or something for each platform), that will then install your app like a commercial application. This will take care of unzipping everything you want in the right directories. There are a couple of free/open-source installers, VAInstall is one that I can think of that aren't too shabby. At work we use Install4J which is pretty good.
    The other way is to use a custom classloader. First, your initial "main" class is nothing but a stub loader. It simply creates an instance of this URLClassloader subclass. You use it to find and run your "real" main() method within the classpath. URLClassLoader has a protected addURL(), but the constructor allows you to pass an array of URL objects, each that can be a directory of .class files or specific .jar/.zip files that become the classpath for the classloader instance. With this info, you can use a custom loader to add each of your .jar files located on disk as part of the classpath. The problem is, if they are on-disk, this isn't helping. What your custom loader needs to do is override loadClass(), getResource() and so forth, and provide a way to find classes from embeded jar/zip libraries inside the main jar file. This way, each time any class uses a class in an embeded jar/zip, your custom classloader looks inside the embeded jar/zip files for it as well. It's not prettty, but it works well.
    One final thought, a plugin engine based application framework is a way to go. My own project, www.platonos.org (sorry, as of this posting the site is not up yet, but the project at sourceforge is available and CVS contains the code) can solve these issues. In our plugin engine, which is about 70K, each plugin has it's own classloader and classpath, and our PluginClassLoader not only handles embeded jar/zip files, but resources as well within them. Also, a plugin first searches its classpath before going to the parent to find classes, with the exception of java classes which are delegated to the bootstrap loader which is what loads rt.jar.

  • Jarsigner - IllegalStateException: zip file closed

    E:\>e:\j2sdk1.4.2\bin\jarsigner.exe -verify -verbose e:\eclipse\startup.jar
    jarsigner: java.lang.IllegalStateException: zip file closed
    any idea? unzip can do unpack the .jar file with no problem
    the jar utility can manage the file:
    E:\>e:\j2sdk1.4.2\bin\jar tf e:\eclipse\startup.jar
    META-INF/
    META-INF/MANIFEST.MF
    org/
    org/eclipse/
    org/eclipse/core/
    org/eclipse/core/launcher/
    org/eclipse/core/launcher/Main$1.class
    org/eclipse/core/launcher/Main$Identifier.class
    org/eclipse/core/launcher/Main$2.class
    org/eclipse/core/launcher/Main.class
    org/eclipse/core/launcher/package.html

    Better late than never...
    http://java.sun.com/j2se/1.4.2/relnotes.html#jarsigner

  • Java security error after 8u31 (Timestamped Jarsigned Applet within valid period of Code Signing certificate)

    Hello,
      I have an applet running in embeddad systems. This program runs without any problem since 8u31 update! After this update it starts to give java security warning and stops running.
    Here is the warning message:
      "Your security settings have blocked an application signed with an expired or not-yet-valid certificate from running"
    What it says is true; my Code Signing Certificate (CSC) is valid between 24 Jan 2014 and 25 Jan 2015. And it expired! However, while i was signing my applet with this certificate i used "timestamp". The authority i choosed was DigiCert. My signing date was 26 Jan 2014 (when my CSC was valid).
    When i started to have this Java Security Error, first i thought i mis-timestamped my code, and check by using the jarsigner -verify command. Here is a partial result:
    s      19607 Mon Jan 27 13:17:34 EET 2014 META-INF/MANIFEST.MF
          [entry was signed on 27.01.2014 13:19]
          X.509, CN=TELESIS TELECOMMUNICATION SYSTEMS, OU=ARGE, O=TELESIS TELECOMMUNICATION SYSTEMS, STREET=TURGUT OZAL BLV.NO:68, L=ANKARA, ST=ANKARA, OID.2.5.4.17=06060, C=TR
          [certificate is valid from 24.01.2014 02:00 to 25.01.2015 01:59]
          X.509, CN=COMODO Code Signing CA 2, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB
          [certificate is valid from 24.08.2011 03:00 to 30.05.2020 13:48]
          X.509, CN=UTN-USERFirst-Object, OU=http://www.usertrust.com, O=The USERTRUST Network, L=Salt Lake City, ST=UT, C=US
          [certificate is valid from 07.06.2005 11:09 to 30.05.2020 13:48]
          X.509, CN=AddTrust External CA Root, OU=AddTrust External TTP Network, O=AddTrust AB, C=SE
          [certificate is valid from 30.05.2000 13:48 to 30.05.2020 13:48]
    sm       495 Thu Jan 23 14:55:22 EET 2014 telesis/WebPhone$1.class
    As you may see the timestamp was correctly done. And it is in the valid period of CSC.
    Than i started to check how Java confirms the Certificate, and found some flowcharts.
    Here is an example from DigiCert:
    Code Signature Verification Process
    After the Web browser downloads the Applet or Web Start application, it checks for a timestamp, authenticates the publisher and Certificate Authority (CA), and checks to see if the code has been altered/corrupted.
    The timestamp is used to identify the validation period for the code signature. If a timestamp is discovered, then the code signature is valid until the end of time, as long as the code remains unchanged. If a timestamp is not discovered, then the code signature is valid as long as the code remains unchanged but only until the Code Signing Certificate expires. The signature is used to authenticate the publisher and the CA, and as long as the publisher (author or developer) has not been blacklisted, the code signature is valid. Finally, the code is checked to make sure that it has not been changed or corrupted.
    If the timestamp (or Code Signature Certificate expiration date) is verified, the signature is validated, and the code is unchanged, then the Web browser admits the Applet or Web Start application. If any of these items do not check out, then the Web browser acts accordingly, with actions dependent on its level of security.
    So according to this scheme, my applet had to work properly, and without security warning.
    However i also found that from Oracle, which also includes the timestamping authorities Certification validity period??? :
    The optional timestamping provides a notary-like capability of identifying
    when the signature was applied.
        If a certificate passes its natural expiration date without revocation,
    trust is extended for the length of the timestamp.
        Timestamps are not considered for certificates that have been revoked,
    as the actual date of compromise could have been before the timestamp
    occurred.
    source:  https://blogs.oracle.com/java-platform-group/entry/signing_code_for_the_long
    So, could anyone please explain why Java gives security error when someone tries to reach that applet?
    Here is a link of applet: http://85.105.68.11/home.asp?dd_056
    I know the situation seems a bit complicated, but i tried to explain as simple as i can.
    waiting for your help,
    regards,
    Anıl

    Hello,
      I have an applet running in embeddad systems. This program runs without any problem since 8u31 update! After this update it starts to give java security warning and stops running.
    Here is the warning message:
      "Your security settings have blocked an application signed with an expired or not-yet-valid certificate from running"
    What it says is true; my Code Signing Certificate (CSC) is valid between 24 Jan 2014 and 25 Jan 2015. And it expired! However, while i was signing my applet with this certificate i used "timestamp". The authority i choosed was DigiCert. My signing date was 26 Jan 2014 (when my CSC was valid).
    When i started to have this Java Security Error, first i thought i mis-timestamped my code, and check by using the jarsigner -verify command. Here is a partial result:
    s      19607 Mon Jan 27 13:17:34 EET 2014 META-INF/MANIFEST.MF
          [entry was signed on 27.01.2014 13:19]
          X.509, CN=TELESIS TELECOMMUNICATION SYSTEMS, OU=ARGE, O=TELESIS TELECOMMUNICATION SYSTEMS, STREET=TURGUT OZAL BLV.NO:68, L=ANKARA, ST=ANKARA, OID.2.5.4.17=06060, C=TR
          [certificate is valid from 24.01.2014 02:00 to 25.01.2015 01:59]
          X.509, CN=COMODO Code Signing CA 2, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB
          [certificate is valid from 24.08.2011 03:00 to 30.05.2020 13:48]
          X.509, CN=UTN-USERFirst-Object, OU=http://www.usertrust.com, O=The USERTRUST Network, L=Salt Lake City, ST=UT, C=US
          [certificate is valid from 07.06.2005 11:09 to 30.05.2020 13:48]
          X.509, CN=AddTrust External CA Root, OU=AddTrust External TTP Network, O=AddTrust AB, C=SE
          [certificate is valid from 30.05.2000 13:48 to 30.05.2020 13:48]
    sm       495 Thu Jan 23 14:55:22 EET 2014 telesis/WebPhone$1.class
    As you may see the timestamp was correctly done. And it is in the valid period of CSC.
    Than i started to check how Java confirms the Certificate, and found some flowcharts.
    Here is an example from DigiCert:
    Code Signature Verification Process
    After the Web browser downloads the Applet or Web Start application, it checks for a timestamp, authenticates the publisher and Certificate Authority (CA), and checks to see if the code has been altered/corrupted.
    The timestamp is used to identify the validation period for the code signature. If a timestamp is discovered, then the code signature is valid until the end of time, as long as the code remains unchanged. If a timestamp is not discovered, then the code signature is valid as long as the code remains unchanged but only until the Code Signing Certificate expires. The signature is used to authenticate the publisher and the CA, and as long as the publisher (author or developer) has not been blacklisted, the code signature is valid. Finally, the code is checked to make sure that it has not been changed or corrupted.
    If the timestamp (or Code Signature Certificate expiration date) is verified, the signature is validated, and the code is unchanged, then the Web browser admits the Applet or Web Start application. If any of these items do not check out, then the Web browser acts accordingly, with actions dependent on its level of security.
    So according to this scheme, my applet had to work properly, and without security warning.
    However i also found that from Oracle, which also includes the timestamping authorities Certification validity period??? :
    The optional timestamping provides a notary-like capability of identifying
    when the signature was applied.
        If a certificate passes its natural expiration date without revocation,
    trust is extended for the length of the timestamp.
        Timestamps are not considered for certificates that have been revoked,
    as the actual date of compromise could have been before the timestamp
    occurred.
    source:  https://blogs.oracle.com/java-platform-group/entry/signing_code_for_the_long
    So, could anyone please explain why Java gives security error when someone tries to reach that applet?
    Here is a link of applet: http://85.105.68.11/home.asp?dd_056
    I know the situation seems a bit complicated, but i tried to explain as simple as i can.
    waiting for your help,
    regards,
    Anıl

  • Failed to load Main-Class manifest attribute from Hello.jar???

    HI all
    This is my first post, I hope its in the right section
    I followed the tutorial on [http://www.cs.princeton.edu/introcs/85application/jar/jar.html|http://www.cs.princeton.edu/introcs/85application/jar/jar.html] and I tried out the simple example below
    A simple example. Let's say we wanted to distribute the simple program Hello.java as a JAR. First, we create a text file named Hello.mf which contains:Manifest-Version: 1.0
    Main-Class: Hello
    Then, we create the archive by typing:
    jar cmf Hello.mf Hello.jar Hello.class Hello.java
    and run it by typing:
    java -jar Hello.jar 
    But when I ran the command java -jar Hello.jar the following error message showed on my command prompt
    Failed to load Main-Class manifest attribute from Hello.jar
    I don't know what I have done wrong, i followed the tutorial to the letter.
    Can anyone shed some light on whats going wrong please?
    Many thanks
    HLA91

    Sorry about double post but i dont know whether editing my first one will bump the thread, and i need it bumped :).
    I downloaded netbeans and I built my project and a jar file was created in oblong/dist (oblong is my project name) but again when i try to run the file the warning
    Failed to load Main-Class manifest attribute from oblong.jar
    appears and I dont know what i can do this time seen as i dont make the manifest file (read prior posts to see what i previously did wrong) , the compiler does it all for me so either im missing something that i have to do before building my project or netbeans is messing up for some strange reason. Can anyone provide insight?
    Many thanks
    HLA91

  • Failed to load Main-Class manifest attribute from jar

    I get this error when i try start a executable jar file:
    Failed to load Main-Class manifest attribute from
    even though i have a
    Main-Class: a.b.c.MyClass
    entry in the meta-inf/manifest.mft
    I also have a (rather long) "Class-Path:" entry preceeding the "Main-Class:" entry in the manifest. What's wrong?

    ant has a major problem with very long "Class-Path" entries in a manifest file.
    The ant manual states, that jars wrap lines in manifest files longer than 72 characters. They say it's not their fault, and they can't do anything about it...
    I need to make an executable jar file with a classpath of approx. 200 characters.
    When i use Netbeans to jar the project, everythings fine.
    But using ant, the Class-Path seems to get messed up and none of the external classes are found, even though the manifest looks just like the one generated by Netbeans and the jar contents are the same.
    One way to workaround this problem is by using a manifest like this:
    Class-Path: some.jar foo.jar
      someother.jar
      guesswhat.jar
    Main-Class: what.everPlease take note of the leading spaces on the second and third Class-Path line.
    But i don't think, there's any way to make ant create a manifest like that using the ant <manifest> tag, because you can only specify a single "Class-Path" attribute, empty attributes are not allowed and if you use ${line.separator} to break lines, the line will still get a hard break after 72 characters. D'uh!
    Looks to me like a case of denial.
    On the other hand, there's another good idea to be found at jakarta:
    http://jakarta.apache.org/commons/sandbox/hivemind/jakarta-hivemind/ant/ManifestClassPath.html
    I'm going to check tomorrow if this might solve the problem.
    Or is there some other magical ingredient missing in the ant generated jar, that the NetBeans generated jar has??
    The most interesting part is, that i can't even make the ant jar run properly, if i call
    java -classpath ... -jar myAnt.jar

  • Jarsigner: invalid END header (bad central directory offset)

    I signed a jar (which is a standalone application) with:
    C:\>jarsigner -keystore myKeystore myJar.jar
    I verified it with
    C:\>jarsigner -verbose -verify myJar.jar
    It was OK.
    I updloaded it to my web site via ftp.
    When I try to to downlod it via Java Web Start, I get a java.util.zip.ZipException.
    If I try to verify it again with jarsigner, I get:
    jarsigner: java.util.zip.ZipException: invalid END header (bad central directory offset).
    Can anyone tell me where the jar file may have been corrupted ?
    Thanks a lot
    Norberto

    You were right, John.
    Thanks a lot.
    I hope to help you one day.
    Norberto:
    Did you remember to ftp myJar.jar in binary mode? As
    I recall, ftp assumes things are ASCII files and does
    funny things to the file if it is actually a binary.
    A good way to check this, I would think would
    calculate the MD5 hash of your signed Jar file just
    after you have signed it and then again on the other
    end after you've FTPed it with "md5sum myJar.jar" (or
    whatever the windows equivalent is, if applicable).
    At least that would be where I'd start to look for
    something that "messed up" your jar file.
    Good luck,
    John

  • Splash screen always messes up on iPhone 5. Must fix so I can submit to the App Store.

    When I start my app on the iPhone 5, the propper [email protected] splash screen shows for a bit and it looks great, but then it changes its mind after a moment and shows the 'legacy' [email protected] one which makes the splash screen look stretched and jarring and unacceptable for being downloaded from the App Store. This seems extremely bizzare for it to hop between splash screens.
    Why does it do this? How can I get the splash screen to not be messed up so I can submit it to the App Store?
    Perhaps there is an actual proper way to explicitly say it supports the iPhone 5 extra screen space in the plist manifest rather than just adding the png that would fix this?
    Since existing AIR apps are broken in iOS 6/iPhone 5, it is important for me to fix this and get the app updated as soon as possible.

    So I just installed AIR 3.5 Beta and SDK for FlashBuilder 4.6. I dropped the splash screen images, [email protected], [email protected], and Default.png in the root of the src folder. I then tested it on an iPhone 4S and while it loads the correct splash screen, [email protected], there is an all white screen in between the time the splash screen disappears and the main application screen loads. It lasts for maybe 2 seconds - defintely noticeable. I am not sure if this previously occurred as I was using a dynamic splash screen based upon DPI, 320 or 160. I assumed that this new method would be an easier route to go since both the 4S and 5 have roughly the same DPI.
    I don't have an iPhone 5 to test it on.
    Thanks.

Maybe you are looking for

  • Disabling Touchpad in UltraNav-Keyboard

    Hello, I'm using an IBM Thinkpad UltraNav-Keyboard (this one) and i'd like to disable the touchpad. I've googled around, and all I've found is that I should make some changes to xorg.conf and/or the hal-policies. I did so, but nothing happend. Even r

  • Modeling Question: Last Item value and First Value

    Dear all, I have the data coming in the following format: Data Source: HEAD1     1     21.01.2005      2     21.01.2005      3     21.01.2005      4     21.01.2005      5     23.01.2005      6     21.01.2005      7     21.01.2005      8     21.01.200

  • I have a 5300 but nothing saves to the memory card...

    I've just bought a 5300 with a 2gb memory card, but all the music & pics i put on it seems to save to the phone & not the card. Have only got about 5 mp3's on it & says memory is full! Does anyone know how to fix this???? Thanks!!

  • Number of messages

    Hi, i have created a condition record for a delivery note. And in communication, i precise 2 as a number of messages. But when i generate the delivery note, only 1 copy print out. What's missing? Thanks for your quick answer.

  • Method usage in Bufferedimage

    I have created a method on using a bufferedimage to draw an image with additional shape on top of the image. But when I run it, the shape cannot display. I try to get help in this forum but still expert said the GeneralPath I created is fine, so I re